Testing Java with Visual Studio Code
Testing Java in Visual Studio Code is enabled by the Java Test Runner extension. It's a lightweight extension to run and debug Java test cases. The extension supports the following test frameworks:
- JUnit 4 (v4.8.0+)
- JUnit 5 (v5.1.0+)
- TestNG (v6.8.0+)
- Run test cases
- Debug test cases
- View test report
- View tests in Test Explorer
Once the test runner is activated, you will find Run|Debug on the CodeLens of your test functions. Click on the CodeLens to run the individual test case. You can also access and run a group of test cases from the Test Explorer. For more information on debugging test cases, see Debugging Java.
Here's a brief session with TestNG:
And with JUnit5:
The JUnit 5 support also covers frequently used annotations such as
You can also view the Test Report and navigate to source from there.
Read on to find out about: