Most of the test files on this site are JUnit 5 testers. This page demonstrates how to run an existing JUnit 5 test in Eclipse, VS Code, and BlueJ. Many other IDEs also support JUnit 5 tests.
For more information on creating JUnit 5 tests and interpreting the results, see the JUnit 5 website.
Sample JUnit 5 test and class being tested:
Running JUnit 5 tests in Eclipse
Configuration:
- Eclipse 2023-12 (4.30.0)
- JDK 17 and compiler compliance level 17
Using a Junit 5 test in an Eclipse project for the first time requires adding JUnit 5 to the build path. Hover over the @Test
annotation (without clicking). Select the quick fix “Add JUnit 5 library to the build path”.
Click the regular Run button to run the test(s).
Running JUnit 5 tests in VS Code
Testing Java with Visual Studio Code demonstrates the process. Follow the instructions for JUnit 5.
Running JUnit 5 tests in BlueJ
BlueJ (at least 5.2.1) supports JUnit 5 tests without additional configuration. Drag the test code into a project. Compile it. Right click the test class and choose “Test All”.