Reputation: 2337
I am trying to use the Junit4 i using the below clases
public class Example extends TestCase {
public Example(String name) {
super(name);
}
@Test
public void exampletest() {
//TO DO
}
}
@RunWith(Suite.class)
@SuiteClasses({ Example.class })
public class Tests {
TestSuite tests = new TestSuite();
tests.addTest(new Example("exampletest"));
}
It gives me No tests found in junit4 exception some one can tell me why i get this exception Or give an example how to do it?
Upvotes: 1
Views: 2235
Reputation: 1943
In JUnit4, you don't make your test cases extend TestCase. But if you do, then your @Test annotations are ignored, and you have to prepend test method names by test. Try this code:
Example.java:
import org.junit.Test;
public class Example {
@Test
public void exampletest() {
//TO DO
}
}
Tests.java:
@RunWith(Suite.class)
@SuiteClasses({ Example.class })
public class Tests {
}
Upvotes: 2