Java Test Automation / Scenario
Escape from TestNG: A Jupiter Migration Review
A TestNG suite is being ported to JUnit 5 and the draft PR crashes at startup, misuses assumptions as soft asserts, and loses skip-on-failure. Review it.
- Difficulty
- Medium
- Format
- Scenario
- Points
- 150
- Estimate
- 13 min
// MISSION BRIEF
Your Mission
Your team is migrating an API suite from TestNG to JUnit 5. The draft PR is up: it compiles, and it is wrong in three educational ways.
You have the original TestNG class, the Jupiter draft, and the startup error. Decide the correct mapping for each TestNG feature: instance @BeforeClass, dependsOnMethods, SoftAssert, groups, and listeners. The goal is a port that keeps the suite's semantics, not just its file names.
// FIRST CONTACT
Battle teaser
First artifact
Original: UserApiTests.java (TestNG)
Fixing the startup crash correctly:
- AEither make boot() static, or annotate the class @TestInstance(Lifecycle.PER_CLASS); the instance-method port fails because Jupiter's default lifecycle is one instance PER TEST
- BRename boot() to setUp(); Jupiter requires that name
- CReplace @BeforeAll with @BeforeEach and accept a new ApiClient per test as equivalent
- DDelete the lifecycle method and initialize client inline at field declaration, which is always identical in behavior
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
javajunit5migrationtestng