Java Test Runner
Run and debug Java test cases in Visual Studio Code
A lightweight extension to run and debug Java test cases in Visual Studio Code. The extension support following test frameworks:
- JUnit 4 (v4.8.0+)
- JUnit 5 (v5.1.0+)
- TestNG (v6.8.0+)
The Java Test Runner works with Language Support for Java by Red Hat and Debugger for Java to provide the following features:
- Run/Debug test cases
- Customize test configurations
- View test report
- View tests in Test Explorer
- Show test logs
Run/Debug Test Cases
- The extension will generate
Run Test and
Debug Test shortcuts (also known as Code Lens) above the class and method definition. Simply click on them will start running or debugging the target test cases.
Note: If you cannot see the Code Lens in your editor, please refer to this issue comment as a workaround.
- The Test Explorer is the place to show all the test cases in your project. You can also run/debug your test cases from here.
- Click the node in the Test Explorer will navigate to the location of the source code.
Note: If the Test Explorer is empty, please refer to this issue comment as a workaround.
Customize Test Configurations
- Sometimes you may want to customize the configuration for running the test cases. To achieve this, you can add it into your workspace settings under the section:
Note: More details can be found here.
View Test Report
- After running/debugging the test cases, the status bar will show the final results. Simply click on it to show the Test Report.
- You can also click the ✔️ or ❌ mark in Code Lens to open the Test Report.
- You can navigate to the source location of the target test case by clicking the navigate button.
Note: You can use
java.test.report.showAfterExecution to configure whether to automatically show the test report after execution. By default, it will be shown when there are failed tests.
|Specify where to show the test report. Supported values are:
|Specify if the test report will automatically be shown after execution. Supported values are:
|Specify whether to show the Code Lenses in editor or not.
|Specify the level of the test logs. Supported values are:
|Specify the configuration for the test cases to run with. More details.
|Specify the name of the default test configuration.
Contributing and Feedback
If you are interested in providing feedback or contributing directly to the code base, please check the document Contributing to Java Test Runner, which covers the following parts:
This extension is licensed under MIT License.
This extension collects telemetry data to help improve our products. Please read Microsoft privacy statement to learn more. If you opt out to send telemetry data to Microsoft, please set below configuration in settings.json:
telemetry.enableTelemetry = false. Learn more in our FAQ.