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
1
vote
0 answers

Customizing and adding more information to junit results

I have junit test cases with a unique id mentioned in method documentation. For example, in the following test cases is XNH233T /** * XNH233T **/ @Test public void testAPlusB(){ } Now, how I can write the ID of each test cases to test results ? I…
amjad
  • 2,876
  • 7
  • 26
  • 43
1
vote
1 answer

Why JUnit "Run as->JUnit" and "Cover as -> Junit" has different behavior?

I have a JUnit test. But when I use "Run as -> JUnit" it will succeed, whereas when I use "Cover as -> JUnit" it will fail. Why is that? The code indeed has some problem. In the code I'm using some legacy code(I have no access to change it) which…
Edmond
  • 614
  • 2
  • 11
  • 26
1
vote
1 answer

Execution order of ScalaTest and JUnit tests using IntelliJ and Maven

My team is using Scala, IntelliJ, and Maven. In the some of the tests I need for the current module I am working on the internal test order of execution is important. For some reason running the same test using JUnit or ScalaTest in IntelliJ effects…
1
vote
1 answer

What is the logic of @Rule(JUnit) declaration and assignment in a Groovy class

Trying some variants of rules creation in a groovy file, I have come to the thought, that @Rule doesn't describe DECLARATION, but ASSIGNMENT. So, the runner, when loading the test, tries every rule for the correct assignment. //Correct…
Gangnus
  • 24,044
  • 16
  • 90
  • 149
0
votes
2 answers

How to group JUnit tests together

I'm trying to create a junit Runner that will group together common tests using the junit API: package whatever; import org.junit.runner.Description; import org.junit.runner.Runner; import org.junit.runner.notification.Failure; import…
uzilan
  • 2,554
  • 2
  • 31
  • 46
0
votes
0 answers

How to create JUnit runner with mail report?

I have a set JUnit test files that reside in different folders and packages. I need to write small java app that will launch all of them and generate html log file. I have do to this without ant. How can I do this?
Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
0
votes
3 answers

Java - Spring and Mockito - Mocking a constructor parameter that is not a field in class?

I have the following Spring component that I am trying to unit test: @Component public class OrderService { private final DatabaseConnection dbConnection; private final String collectionName; @Autowired public OrderService( …
java12399900
  • 1,485
  • 7
  • 26
  • 56
0
votes
0 answers

Annotation @RunWith(MockitoJUnitRunner::class) is not initializing mocks in Kotlin

I am trying to write a test class in Kotlin with org.jetbrains.kotlin:kotlin-test-junit:1.4.31 in my build.gradle. In my test class, mocks are not getting initialized via the '@RunWith' annotation i.e. : @RunWith(MockitoJUnitRunner::class) e.g. I…
Akash Verma
  • 638
  • 1
  • 11
  • 15
0
votes
1 answer

Initialize beans in inner Static test class in springBoot

I am using nested classes for writing unit test cases in spring boot. My test case file is : @RunWith(NestedRunner.class) @SpringBootTest @TestInstance @AutoConfigureMockMvc public class OuterTestCase { public static class InnerTestCases…
0
votes
1 answer

Stopping test runner after first failing test

We have created a custom test runner for Junit 5. However, we would like to stop this runner after the first failing test. I've looked into Extensions, but these all work with ExtensionContext which does not seem to provide any way to stop the…
dstibbe
  • 1,589
  • 18
  • 33
0
votes
0 answers

SpringJUnit4ClassRunner and @ContextConfiguration not found

First of all I don't use SpringBoot, it is pure old Spring application. I was thinking about adding some test for learning purposes so I need to mock/setup application context somehow. I am trying to implement such…
Mateusz Gebroski
  • 1,274
  • 3
  • 26
  • 57
0
votes
1 answer

Mock config.getInt()

How can I mock config.getInt("getNoOfDays",100) in MockitoJUnitRunner? I have tried @Test(expected = IllegalStateException.class) public void populateAddress() { …
0
votes
0 answers

how to use @Mock and @Autowired in Junit5 unit test?

I want to use both @Autowired and @Mock. For Example, I don't want to mock conversionService, I want to autowire it and mock other services.
0
votes
3 answers

io.cucumber.core.gherkin.FeatureParserException: Failed to parse resource at

I am trying to build a framework using io.cucumber but gives me an error which mentions in the title TestRunner File package Test_Runner; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import…
ddjadav
  • 71
  • 1
  • 3
  • 10
0
votes
1 answer

j2objc adding source class dependency for junit test class

I am very new to j2objc and have a question about translating junit test classes. I have a class (Foo.java) and a corresponding test class (FooTest.java). I am following steps from this link to translate the test class written in java.…
learner
  • 139
  • 1
  • 13
1 2 3
8 9