Run and debug Java test cases in Visual Studio Code.
Перейти к файлу
Sheng Chen 39602e7e85
test: Refactor the test code (#1170)
2021-04-09 12:30:13 +08:00
.github test: Refactor the test code (#1170) 2021-04-09 12:30:13 +08:00
.vscode test: Refactor the test code (#1170) 2021-04-09 12:30:13 +08:00
demo Prepare for 0.22.1 release (#928) 2020-01-18 19:10:34 +08:00
java-extension chore: Prepare 0.28.1 (#1147) 2021-03-02 10:53:57 +08:00
resources chore: Apply 256*256 extension logo (#1148) 2021-03-03 10:07:45 +08:00
src fix: Always show last execution result when click show results from code lens (#1168) 2021-04-08 11:27:56 +08:00
test test: Refactor the test code (#1170) 2021-04-09 12:30:13 +08:00
.gitignore feat: Adapt test runner for all JUnit 5 Platform Engines (#980) 2020-05-27 13:28:48 +08:00
.vscodeignore chore: Prepare for 0.28.0 (#1132) 2021-02-02 13:58:12 +08:00
CHANGELOG.md chore: Prepare 0.28.1 (#1147) 2021-03-02 10:53:57 +08:00
CONTRIBUTING.md Add more content to the contribution guide (#985) 2020-04-28 07:49:30 +08:00
LICENSE.txt Re-structure the repo (#473) 2018-11-29 16:02:21 +08:00
README.md chore: Apply the new extension logo (#1144) 2021-03-01 15:59:04 +08:00
extension.bundle.ts Show test report from keyboard shorcut (#1023) 2020-07-07 14:47:42 +08:00
gulpfile.js fix: Improve the accessibility of the test report (#1130) 2021-01-26 11:28:06 +08:00
javaConfig.json chore: support to debug Java side code in VS Code (#786) 2019-08-26 17:15:34 +08:00
main.js Add JUnit 4 E2E tests for Code Lens (#864) 2019-11-13 09:49:43 +08:00
package-lock.json test: Refactor the test code (#1170) 2021-04-09 12:30:13 +08:00
package.json chore: Update npm depndencies (#1169) 2021-04-08 16:15:21 +08:00
package.nls.json feat: Add welcome view when no folder opened (#1141) 2021-02-26 16:06:35 +08:00
package.nls.zh.json feat: Add welcome view when no folder opened (#1141) 2021-02-26 16:06:35 +08:00
tsconfig.json chore: Check no implicit any (#1107) 2020-11-25 16:52:43 +08:00
tslint.json chore: Adopt progress reporter API (#1119) 2021-01-05 09:23:37 +08:00
webpack.config.js chore: Update npm depndencies (#1169) 2021-04-08 16:15:21 +08:00

README.md

Java Test Runner

Run and debug Java test cases in Visual Studio Code

Overview

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+)

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

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

Requirements

Quickstart

Run/debug JUnit test

Getting Started for JUnit 5

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

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.

Getting Started for JUnit 4

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

Getting Started for TestNG

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

Features

Run/Debug Test Cases

Run Code Lens

  • 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.


Test Explorer

Run Explorer

  • 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

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: java.test.config.

Note: More details can be found here.


View Test Report

Status Bar

  • 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.

Status Bar

  • 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.

Settings

Setting Name Description Default Value
java.test.report.position Specify where to show the test report. Supported values are: sideView, currentView. sideView
java.test.report.showAfterExecution Specify if the test report will automatically be shown after execution. Supported values are: always, onFailure, never. onFailure
java.test.editor.enableShortcuts Specify whether to show the Code Lenses in editor or not. true
java.test.log.level Specify the level of the test logs. Supported values are: error, info, verbose. info
java.test.config Specify the configuration for the test cases to run with. More details. {}
java.test.defaultConfig Specify the name of the default test configuration. ""

FAQ

If you meet any problem when using the extension, please refer to the FAQ 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 Java Test Runner, 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.