Interview Questions

Can You Explain the Life Cycle of a JUnit 4.4 Test Class?

JUnit Questions and Answers


(Continued from previous question...)

Can You Explain the Life Cycle of a JUnit 4.4 Test Class?

A JUnit 4.4 test class contains a @Before method, an @After method and multiple @test methods. When calling a test runner to run this test class, the runner will execute those methods in a specific order giving the test class an execution life cycle like this:

@Before
@Test XXX1
@After

@Before
@Test XXX2
@After

@Before
@Test XXX3
@After

...

(Continued on next question...)

Other Interview Questions