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+)
The Java Test Runner works with the Language Support for Java by Red Hat and Debugger for Java extensions to provide the following features:
- Run test cases
- Debug test cases
- View test report
- View tests in Test Explorer
Here's a brief session with TestNG:

And with JUnit5:

The JUnit 5 support also covers frequently used annotations such as @DisplayName and @ParameterizedTest


Visit the GitHub repository of the Java Test Runner for more details on commands and settings.
Next steps
Read on to find out about:
- Debugging - Find out how to debug your Java project with VS Code.
- Java Extensions - Learn about more useful Java extensions for VS Code.