Parameter | Context | Details |
---|---|---|
@BeforeClass | Static | Executed when the class is first created |
@Before | Instance | Executed before each test in the class |
@Test | Instance | Should be declared each method to test |
@After | Instance | Executed after each test in the class |
@AfterClass | Static | Executed before destruction of the class |
Example Test Class Format
public class TestFeatureA {
@BeforeClass
public static void setupClass() {}
@Before
public void setupTest() {}
@Test
public void testA() {}
@Test
public void testB() {}
@After
public void tearDownTest() {}
@AfterClass
public static void tearDownClass() {}
}
}