JUnit Maven Dependency
Basic annotations @Before, @After, @BeforeClass, @AfterClass
Executed before every @Test method
Executed after every @Test method
Executed once before all @Test methods
Executed once after all @Test methods
Test methods annotation. @Test
For time limited (in milliseconds) tests use @Test(timeout = 5000)
For testing of exceptions use @Test(expected = SomeSpecificException.class)
Parameterized tests
The class should be declared with @RunWith(Parameterized.class) annotation.
You should provide the method with @Parameters annotation that returns collection of arrays. Every test will be executed with each array as with a parameters set
You have to have the constructor method with arguments corresponding to Object[] mentioned above.
JUnit Assertions
JUnit Test suites
You can use Suite classes as containers for your tests. @Suite.SuiteClasses defines classes that are included into the suite and the order of execution.
Leave the suite class empty
Need more?
You may also find these posts interesting: