Top "Junit4" questions

Version 4 of the popular Junit Java Unit testing framework

When using JUnit's @Parameterized, can I have some tests still run only once

I use @Parameterized in many cases to run tests on a number of permutations. This works very well and keeps …

java junit junit4 parameterized
junit testing with gradle for an android project

I am trying to get tests ( junit and robolectric ) working in an Android project but am totally stuck. My main …

android junit gradle junit4 robolectric
assertEquals, what is actual and what is expected?

I always wondered what exactly is the meaning of actual and expected in assertEquals in libraries like TestNG. If we …

java unit-testing testing testng junit4
How do I validate that the @RequestParams are not empty?

I have a calculator service that gets the operation type, num1 and num2 from the user. I need to validate …

java spring-boot junit4 bean-validation jsr
Specifying an order to junit 4 tests at the Method level (not class level)

I know this is bad practice, but it needs to be done, or I'll need to switch to testng. Is …

java unit-testing junit4 junit3
How to write a Unit Test for JAXB 2.0 Marshalling

I am using Jaxb 2.0 api without using XSD, and have created the content model using annotations. I want to write …

marshalling junit4 jaxb2
System.out.print doesn't output to console when running from Junit

When running: public static void main(String... args) throws InterruptedException { while (true) { System.out.print("."); Thread.sleep(200); } } vs. when running …

java multithreading junit junit4 system.out
How to reset between tests

I have a test class @RunWith(SpringRunner.class) @DataJpaTest I have two tests. In every test I do the same …

java spring spring-boot spring-data-jpa junit4
Verify Static Method Call using PowerMockito 1.6

I am writing JUnit test case for methods similar to sample given below: Class SampleA{ public static void methodA(){ boolean …

java mockito junit4 powermock powermockito
Migrating Junit4 tests to androidx: What causes 'delegate runner could not be loaded'?

I am migrating my app to androidx, I can't seem to get my unit tests working. I took example from …

android junit junit4 androidx