JUnit 4 uses annotations, so naming convention is no more needed, which means
For Test Suite:
- Test suite class doesn't have to extend the TestSuite class.
- adding test cases is different from the way in JUnit 3
@RunWith(Suite.class)
@Suite.SuiteClasses({
testclass1.class;
testclass2.class;
...
})
public class MyTestCases{
}
For Test Cases:
- the test class doesn't have to extend TestCase
- the test method name doesn't have to start with test
@Test
annotates test method in test class.
@Before and @After
test method level setUp and tearDown, they run before and after every test case.
@BeforeClass and @AfterClass
class level setUp and tearDown, they run once before and after all test cases.
@Ignore
ignore the test case, for example: @Ignore ("Not ready to run for now.")