/** * Show the execution order of each annotations. * Given this test, the methods will execute in the following order: * oneTimeSetUp() * setUp() * testMyFunction1() * tearDown() * setUp() * testMyFunction2() * tearDown() * oneTimeTearDown() * * @author: Xuan Ngo */ import org.junit.*; public class JUnitCheatSheet { @BeforeClass public static void oneTimeSetUp() { // one-time initialization code System.out.println("oneTimeSetUp()"); } @AfterClass public static void oneTimeTearDown() { // one-time cleanup code System.out.println("oneTimeTearDown()"); } @Before public void setUp() { // Run before every test methods. System.out.println("setUp()"); } @After public void tearDown() { // Run after every test methods. System.out.println("tearDown()"); } @Test public void testMyFunction1() { // Test MyFunction 1. System.out.println("testMyFunction1()"); } @Test public void testMyFunction2() { // Test MyFunction 2. System.out.println("testMyFunction2()"); } }