Top "Junit4" questions

Version 4 of the popular Junit Java Unit testing framework

How to handle ordering of @Rule's when they are dependent on each other

I use embedded servers that run inside Junit test cases. Sometimes these servers require a working directory (for example the …

java junit junit4
Spring Boot Integration Testing with mocked Services/Components

Situation and Problem: In Spring Boot, how can I inject one or more mocked classes/beans into the application to …

java spring-boot junit4 spring-test
How to mock UUID.randomUUID() from java.util package?

What is wrong with the UUID.randomUUID() - it just can't be mocked Is it possible to mock? Or i …

java junit4 powermockito
How to parameterize junit Test Suite

Is it possible to parameterize a TestSuite in junit 4 ? For declaring a class as a test suite I need the …

java junit4 junit-runner
java.lang.IllegalStateException: JMockit wasn't properly initialized; check that jmockit.jar precedes junit.jar in the classpath

I am getting below exception when i am trying to runing the Junit testcases. If i am changing the classpath …

code-coverage junit4 jmockit
JUnit @Before vs @Rule

I understand that, @Before and @BeforeClass run before each test, or the entire test class, respectively @Rule and @ClassRule wraps …

java junit junit4
How to exclude all JUnit4 tests with a given category using Maven surefire?

I intend on annotating some of my JUnit4 tests with an @Category annotation. I would then like to exclude that …

junit maven-2 junit4 maven-surefire-plugin
Use different Spring test context configuration for different test methods

We have a Spring based JUnit test class which is utilizing an inner test context configuration class @RunWith(SpringJUnit4ClassRunner.…

java spring junit junit4 spring-test
Espresso UI testing doesn't recognize onView()

I have spent all day setting up Junit4 instrumentation tests with Espresso, but just can't seem to get that final …

java android android-gradle-plugin junit4 android-espresso
Difference between JUnit Theories and Parameterized Tests

What is the difference between a Theory and a Parameterized test? I'm not interested in implementation differences when creating the …

java junit4 parameterized