Junit Deepdive Part1quiz

This short review quiz is related to the previous article here.

1. What JUnit version introduced annotations for handling the simple lifecycle?

3. Why should you prefer @Before annotated methods in comparison to the constructor? Because

4. Can you use more than one @Before annotated method in a test class?

5. Which method qualifiers must be used for a @AfterClass method?

6. What happens if a public method is annotated with @Before, @Test and @After?

7. What is the simplest way (considering clean code) to handle exceptions?

8. What is the result of the following code?

 1 public class LifecycleTest {
 2 
 3     @Before
 4     public void before() {
 5         System.out.print("3");
 6     }
 7 
 8     public LifecycleTest() {
 9         System.out.print("2");
10     }
11 
12     @BeforeClass
13     public static void beforeClass() {
14         System.out.print("1");
15     }
16 
17     @Test
18     public void test() {
19         System.out.print("4");
20     }
21 
22     @Test
23     public void test2(){
24         System.out.print("5");
25     }
26 
27     @After
28     public void after() {
29         System.out.print("6");
30     }
31 }

The solutions can be found here in white color: 1c; 2acd; 3a; 4bc; 5c; 6b; 7d;