TestNG and JUnit 5 overlap heavily but differ in annotations, suite configuration, grouping, dependencies, data-driven support, soft assertions, and default behaviors — differences interviewers frequently probe.
Key differences: (1) Annotations — TestNG uses @BeforeMethod/@BeforeClass/@BeforeSuite; JUnit 5 uses @BeforeEach/@BeforeAll (and @BeforeAll must be static). (2) Suite config — TestNG has testng.xml; JUnit 5 uses @Suite/tags and build config. (3) Grouping — TestNG @Test(groups=...); JUnit 5 @Tag. (4) Dependencies — TestNG dependsOnMethods; JUnit 5 intentionally omits test dependencies. (5) Data-driven — TestNG @DataProvider; JUnit 5 @ParameterizedTest with sources. (6) Soft assertions — TestNG SoftAssert built-in; JUnit 5 uses assertAll. (7) Parallelism — TestNG via XML; JUnit 5 via properties. Both support timeouts, disabling, and exception testing with different syntax.
Migrating a suite from JUnit to TestNG, the team maps @BeforeEach→@BeforeMethod, @Disabled→@Test(enabled=false), and JUnit @ParameterizedTest→@DataProvider, then gains testng.xml grouping and parallel config.
Name three concrete differences between TestNG and JUnit 5 that affect how you'd write a suite.