← Quiz: TestNG: all 10 questions
Quiz: TestNG · Question 6 of 10
Which annotation runs once before all the tests in a class?
Which annotation runs once before all the tests in a class?
- A.@BeforeMethod
- B.@BeforeClass
- C.@BeforeSuite
- D.@Test(priority = 0)
Answer & explanation
Correct answer: @BeforeClass
@BeforeMethod runs before every test; @BeforeClass runs once per class.
Can you get the rest right without peeking?
Take the timed Quiz: TestNG quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →