JUnit 4 test classes need to be public
and have a public
no-arg constructor or no constructor at all
(implicit default constructor) and no other public
constructors.
JUnit 3 test classes need to be public
and need either a public
no-arg constructor
or a public
constructor with a single parameter of String
type, which calls the matching super constructor.
Otherwise the test classes cannot be run by standard JUnit test runners.
Example:
public class MyTest {
private MyTest() {} // no-arg constructor is private
@Test
public void testSomething() {
assertEquals(1, 1);
}
}