Questions tagged [junit-runner]

The JUnit runner checks, makes and launches the unit tests.

The default runner implementation guarantees that the instances of the test case class will be constructed immediately before running the test and that the runner will retain no reference to the test case instances, generally making them available for garbage collection

124 questions
63
votes
7 answers

Writing a single unit test for multiple implementations of an interface

I have an interface List whose implementations include Singly Linked List, Doubly, Circular etc. The unit tests I wrote for Singly should do good for most of Doubly as well as Circular and any other new implementation of the interface. So instead of…
ChrisOdney
  • 6,066
  • 10
  • 38
  • 48
17
votes
1 answer

Junit5 with spring-boot 1.5

I have a spring-boot application which uses spring-boot version 1.5.9.RELEASE. To test this application I want to use junit-jupiter version 5.0.2. For simple service tests it works without any problems. But when it comes to testing rest endpoints, I…
tgr
  • 3,557
  • 4
  • 33
  • 63
14
votes
2 answers

Activity in androidTest not getting launched by ActivityTestRule

I want to test a fragment in test activity. I added TestTragmentActivity to androidTest along with AndroidManifest.xml file. But when I try to use this activity via an ActivityTestRule it gives following error: java.lang.RuntimeException: Could not…
10
votes
3 answers

Globally setting a JUnit runner instead of @RunWith

Without looking into JUnit source itself (my next step) is there an easy way to set the default Runner to be used with every test without having to set @RunWith on every test? We've got a huge pile of unit tests, and I want to be able to add some…
Andrew Mellinger
  • 319
  • 3
  • 14
10
votes
2 answers

Parameterized jUnit test without changing runner

Is there a clean way to run parameterized jUnit 4 tests without changing the runner, i.e. without using @RunWith(Parameterized.class)? I have unit tests which require a special runner already and I can't replace this one with Parameterized. Maybe…
Wolfgang
  • 2,367
  • 23
  • 29
10
votes
1 answer

how to combine @RunWith with @RunWith(Parameterized.class)

I implemented a runner class A.class inherited from BlockJUnit4ClassRunner so that I can annotate tests with @RunWith(A.class). At the same time, sb. else annotate the tests with RunWith(Parameterized.class). It is obvious we cannot use two @RunWith…
user389955
  • 9,605
  • 14
  • 56
  • 98
8
votes
1 answer

How can I use a custom runner when using categories in Junit?

I have a bunch of JUnit tests that extend my base test class called BaseTest which in turn extends Assert. Some of my tests have a @Category(SlowTests.class) annotation. My BaseTest class is annotated with the following annotation…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
8
votes
0 answers

Multiple JUnit XML results on Jenkins, publish with separate graph?

I have multiple tests running as a part of Android Jenkins build including Unit test and Functional tests. I am able to publish the test results on Jenkins successfully but I want to see seperate result graph for Unit tests and Functional Test.…
Testing Singh
  • 1,347
  • 1
  • 15
  • 26
8
votes
3 answers

Is it possible to mock a static method on a final class using a PowerMockRule instead of the PowerMockRunner?

According to the PowerMock docs, I should be able to run using a PowerMockRule instead of @RunWith(PowerMockRunner.class) and get the same results. I seem to have found a case where this isn't true. The below sample runs fine: package…
Tom Tresansky
  • 19,364
  • 17
  • 93
  • 129
7
votes
1 answer

junit implementation of multiple runners

I have been trying to create a personalized test suite by creating a suiterunner which extends runner. In the test suite which is annotated with @RunWith(suiterunner.class) i am referring to the test classes which need to be executed. Within the…
vpradhan
  • 161
  • 2
  • 7
7
votes
0 answers

Custom JUnit Runner which delegate to standard runners

I'm currently creating a unit custom JUnit runner (which will precisely call custom code before/after each test method) e.g. class MyRunner extends BlockJUnit4ClassRunner { private MyApi api = new MyApi(); public MyRunner(Class klass)…
bobmarksie
  • 3,282
  • 1
  • 41
  • 54
7
votes
3 answers

How can I run kotlintest tests with gradle?

The kotlintest tests run perfectly fine when started from Intellij, but when I try to run them with the gradle test task command, only my regular JUnit tests are found and run. The kotlintest code: import io.kotlintest.matchers.shouldBe import…
Fabian
  • 1,982
  • 4
  • 25
  • 35
6
votes
4 answers

No tests found when using custom runner

I'm using androidx.test libraries(which I migrated to recently) in my project and using custom AndroidJUnitRunner. Before migration it was all working fine but now I'm getting this error - Started running tests Test running failed: Instrumentation…
Shadab Ansari
  • 7,022
  • 2
  • 27
  • 45
6
votes
3 answers

Spring boot Model mapper Unsatisfied Dependency exception

I have the spring boot application that runs without exception when I remove the basic application test. But it shows the following exception when I add the application test…
kaviya .P
  • 469
  • 3
  • 11
  • 27
6
votes
2 answers

How to run JUnit 5 suite without @RunWith annotation

For suites I am using below template: @RunWith(JUnitPlatform.class) @SelectPackages("com.services.configuration") @ExcludeTags({IntegrationTags.JPA, IntegrationTags.REST}) public class UnitTestSuite { } @RunWith is a JUnit 4 dependency, which comes…
Beri
  • 11,470
  • 4
  • 35
  • 57
1
2 3
8 9