Testing / JUnit6 Interview Questions
What modules were removed in JUnit 6 and what replaced them?
JUnit 6 removed several modules that had been deprecated across JUnit 5.x releases. Understanding what was removed and what replaced it is important for migration.
| Removed module | What it did | Replacement in JUnit 6 |
|---|---|---|
| junit-platform-runner | JUnit 4 @RunWith(JUnitPlatform.class) runner for running JUnit Platform tests via JUnit 4 infrastructure | Use @Suite and @SelectClasses from junit-platform-suite directly |
| junit-platform-jfr | Provided Java Flight Recorder (JFR) events for test discovery and execution | JFR support is now built into the launcher itself; no separate module needed |
| junit-platform-suite-commons | Internal commons for suite support | Merged into junit-platform-suite-api |
| MethodOrderer.Alphanumeric | Alphabetical test method ordering | Use MethodOrderer.DEFAULT or MethodOrderer.MethodName |
| JUnit Vintage (deprecated) | Runs JUnit 3/4 tests | Still present but deprecated; will be removed in a future major version |
// JUnit 5: @RunWith(JUnitPlatform.class) -- REMOVED @RunWith(JUnitPlatform.class) // Does not exist in JUnit 6 public class MyJUnit4Suite { ... } // JUnit 6: use @Suite directly @Suite @SelectClasses({OrderTest.class, UserTest.class}) public class MyTestSuite { } // JUnit 5: MethodOrderer.Alphanumeric -- REMOVED @TestMethodOrder(MethodOrderer.Alphanumeric.class) // Compile error in JUnit 6 class OldOrderedTest { ... } // JUnit 6: use MethodOrderer.MethodName instead @TestMethodOrder(MethodOrderer.MethodName.class) class OrderedTest { ... } // Check for removed APIs before upgrading: // grep -r "JUnitPlatform\|Alphanumeric\|platform-runner\|platform-jfr" src/
More Related questions...