Java Test Automation / Quiz

Before and After: The TestNG Lifecycle Ladder

@BeforeSuite to @AfterSuite, and the @BeforeMethod vs @BeforeClass call every framework author has to get right.

Difficulty
Easy
Format
Quiz
Points
100
Estimate
8 min

// MISSION BRIEF

Your Mission

Every TestNG framework stands on its configuration methods. Put WebDriver setup at the wrong rung of the ladder and you get shared-state bleed between tests, or a browser per test where one would do.

This quiz covers the lifecycle ladder, what runs when, what happens when setup fails, and which annotations actually exist.

// FIRST CONTACT

Battle teaser

Which sequence is the correct TestNG execution order at the start of a run?

  1. A@BeforeClass, then @BeforeSuite, then @BeforeTest, then @BeforeMethod, then @Test
  2. B@BeforeMethod, then @BeforeClass, then @BeforeTest, then @BeforeSuite, then @Test
  3. C@BeforeSuite, then @BeforeTest, then @BeforeClass, then @BeforeMethod, then @Test
  4. D@BeforeTest, then @BeforeSuite, then @BeforeMethod, then @BeforeClass, then @Test
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

javatestnglifecycle