Multiple choice

Which of the following annotation causes that method to be run before each Test method?

  1. @Test

  2. @After

  3. @BeforeClass

  4. @Before

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In JUnit 4, the @Before annotation is used on a method to indicate that it should be executed before each @Test method in the class. @BeforeClass runs once before any tests in the class, while @After runs after each test.