Version 1.58 is now available! Read about the new features and fixes from June.
Dismiss this update
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:
Note: More information about the test frameworks can be found at JUnit and TestNG.
The Java Test Runner works with the Language Support for Java by Red Hat and Debugger for Java extensions to provide the following features:
If you run into any issues when using the features below, you can contact us by clicking the Report an issue button below.
Make sure you have the below tools available already
You may refer to Java Extensions to set up the environment.
Note: More information about JDK can be found at supported Java versions.
Please refer to Getting Started from the JUnit 5 official documentation.
Note: You can use junit-platform-console-standalone.jar in projects that manually manage their dependencies similar to the plain-old JAR known from JUnit 4.
Please refer to Download and Install from the JUnit 4 official documentation.
Please refer to TestNG Docs from the TestNG official documentation.
When you open a project with test cases from supported frameworks, Test Runner will be activated and 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:
Note: If you cannot see the CodeLens in your editor, please refer to this issue comment as a workaround.
Note: If the Test Explorer is empty, please refer to this issue comment as a workaround.
java.test.config
.Note: More details can be found in Run with Configuration.
The JUnit 5 support covers frequently used annotations such as @DisplayName
, @ParameterizedTest
, @TestFactory
, @TestTemplate
, and @Nested
. It also supports meta-annotations and composed annotations.
If you meet any problem when using the extension, you can refer to the FAQ to check if there is an answer to your problem.
Visit the GitHub repository of the Java Test Runner for more details on commands and settings.
Read on to find out about: