Home

Awesome

Test Runner for Java

Run and debug Java test cases in Visual Studio Code

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/resources/logo.png" width="128" height="128" alt=""> </p> <p align="center"> <a href="https://github.com/microsoft/vscode-java-test/actions/workflows/build.yml?query=branch%3Amain"> <img src="https://img.shields.io/github/actions/workflow/status/microsoft/vscode-java-test/build.yml?style=flat-square" alt=""> </a> <a href="https://gitter.im/microsoft/vscode-java-test"> <img src="https://img.shields.io/gitter/room/microsoft/vscode-java-test.svg?style=flat-square" alt=""> </a> <a href="https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test"> <img src="https://img.shields.io/visual-studio-marketplace/d/vscjava.vscode-java-test.svg?style=flat-square" alt=""> </a> </p>

Overview

A lightweight extension to run and debug Java test cases in Visual Studio Code. The extension support following test frameworks:

Note: JUnit 3 styled tests are not supported in this extension (i.e. extends junit.framework.TestCase).

The Test Runner for Java works with Language Support for Java by Red Hat and Debugger for Java to provide the following features:

Requirements

Features

Run/Debug Test Cases

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/editor-decoration.png" alt="Run/Debug Test Cases"/> </p>

Test Explorer

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/test_explorer.png" alt="Test Explorer"/> </p>

Customize Test Configurations

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/configuration.png" alt="Customize Test Configurations"/> </p>

Note: More details can be found here.


View Test Result

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/test_report.png" alt="View Test Result"/> </p>

VS Code Embedded Commands for Testing

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/command_palette.png" alt="VS Code Embedded Commands for Testing"/> </p>

There are other VS Code embedded commands for testing, which can be found by searching Test: in the Command Palette.

Settings

Setting NameDescriptionDefault Value
java.test.configSpecify the configuration for the test cases to run with. More details.{}
java.test.defaultConfigSpecify the name of the default test configuration.""

VS Code Embedded Settings for Testing

<p align="center"> <img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/settings.png" alt="VS Code Embedded Settings for Testing"/> </p>

There are some other VS Code embedded settings for testing, which can be found by searching testing in the Settings view.

Project Setup

JUnit 5

Please refer to Getting Started from the JUnit 5's official document for getting started documentation.

Note: If your project does not use build tools(Maven/Gradle/...), please make sure junit-platform-console-standalone.jar is on your project classpath.

JUnit 4

Please refer to Download and Install from the JUnit 4's official document for the getting started documentation.

TestNG

Please refer to TestNG Docs from the TestNG's official document for getting started documentation.

FAQ

If you meet any problem when using the extension, please refer to the FAQ and our issue list to check if there is an answer to your problem.

Contributing and Feedback

If you are interested in providing feedback or contributing directly to the code base, please check the document Contributing to Test Runner for Java, which covers the following parts:

License

This extension is licensed under MIT License.

Telemetry

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.