🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.@BeforeMethod
  2. B.@BeforeClass
  3. C.@BeforeSuite
  4. 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 →