Edit and formatting pass on recent update

This commit is contained in:
gregvanl 2021-08-06 07:38:21 -04:00
Родитель f9a2c16b98
Коммит ca0c34a9ad
8 изменённых файлов: 34 добавлений и 42 удалений

Просмотреть файл

@ -9,6 +9,8 @@ Topics submitted here will be published to the [Visual Studio Code](https://code
If you are looking for the VS Code product GitHub repository, you can find it [here](https://github.com/microsoft/vscode).
>**Note**: The vscode-docs repository uses [Git LFS](https://git-lfs.github.com/) (Large File Storage) for storing binary files such as images and `.gif`s. If you are contributing or updating images, please enable Git LFS per the instructions in the [Contributing](#cloning) section below.
## Index
- [Index](#index)

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 13 KiB

После

Ширина:  |  Высота:  |  Размер: 130 B

Двоичные данные
docs/java/images/java-testing/configuration.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 16 KiB

После

Ширина:  |  Высота:  |  Размер: 130 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 15 KiB

После

Ширина:  |  Высота:  |  Размер: 130 B

Двоичные данные
docs/java/images/java-testing/settings.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 22 KiB

После

Ширина:  |  Высота:  |  Размер: 130 B

Двоичные данные
docs/java/images/java-testing/test_explorer.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 15 KiB

После

Ширина:  |  Высота:  |  Размер: 130 B

Двоичные данные
docs/java/images/java-testing/test_report.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 40 KiB

После

Ширина:  |  Высота:  |  Размер: 130 B

Просмотреть файл

@ -4,14 +4,14 @@ Area: java
TOCTitle: Testing
ContentId: 82be3b78-2c09-4571-abec-69f95f111e0f
PageTitle: Java Unit Tests in Visual Studio Code
DateApproved: 4/14/2021
DateApproved: 8/6/2021
MetaDescription: See how you can test your Java code in Visual Studio Code.
MetaSocialImage:
---
# Testing Java with Visual Studio Code
Testing Java in Visual Studio Code is enabled by the [Java Test Runner](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test) extension. It's a lightweight extension to run and debug Java test cases.
Testing Java in Visual Studio Code is enabled by the [Java Test Runner](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test) extension. It's a lightweight extension to run and debug Java test cases.
## Overview
@ -21,7 +21,7 @@ The extension supports the following test frameworks:
- [JUnit 5](https://junit.org/junit5/) (v5.1.0+)
- [TestNG](https://testng.org/doc/) (v6.8.0+)
> Note: JUnit 3 styled tests are not supported in this extension (i.e. extends `junit.framework.TestCase`).
> Note: JUnit 3 styled tests are not supported in this extension (for example, `extends junit.framework.TestCase`).
The [Java Test Runner](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test) works with the [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) and [Debugger for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug) extensions to provide the following features:
@ -46,52 +46,38 @@ If you run into any issues when using the features below, you can contact us by
## Features
### Run/Debug Test Cases
<p align="center">
<img src="images/java-testing/editor-decoration.png" alt="Run/Debug Test Cases"/>
</p>
- The extension will generate shortcuts (the green play button) on the left side of the class and method definition. To run the target test cases, simply click on the green play button. You can also right click on it to see more options.
The extension will generate shortcuts (the green play button) on the left side of the class and method definition. To run the target test cases, select the green play button. You can also right-click on the play button to see more options.
---
![Run/Debug Test Cases](images/java-testing/editor-decoration.png)
### Test Explorer
<p align="center">
<img src="images/java-testing/test_explorer.png" alt="Test Explorer"/>
</p>
The Test Explorer shows all the test cases in your workspace. You can also run/debug your test cases from there.
- The Test Explorer is the place to show all the test cases in your workspace. You can also run/debug your test cases from here.
![Test Explorer](images/java-testing/test_explorer.png)
---
### Customize test configurations
### Customize Test Configurations
<p align="center">
<img src="images/java-testing/configuration.png" alt="Customize Test Configurations"/>
</p>
Sometimes you may want to customize the configuration to run your test cases. To achieve this, you can add the configuration into your workspace [settings](/docs/getstarted/settings.md) under the section: `java.test.config`.
- Sometimes you may want to customize the configuration to run your test cases. To achieve this, you can add the configuration into your workspace settings under the section: `java.test.config`.
![Customize test configurations](images/java-testing/configuration.png)
> Note: More details can be found [here](https://github.com/Microsoft/vscode-java-test/wiki/Run-with-Configuration).
More details can be found on the [vscode-java-test Wiki](https://github.com/Microsoft/vscode-java-test/wiki/Run-with-Configuration).
---
### View test results
### View Test Result
After running/debugging the test cases, the state of the related test items will be updated in both editor decorations and the Test Explorer.
<p align="center">
<img src="images/java-testing/test_report.png" alt="View Test Result"/>
</p>
![View test results](images/java-testing/test_report.png)
- After running/debugging the test cases, the state of the related test items will be updated in both editor decoration and test explorer.
- You can trigger the command `Test: Peek Output` to peek the result view.
- You can click on the links in the stack trace to navigate to the source location.
You can trigger the command **Test: Peek Output** to peek the results view. You can select the links in the stack trace to navigate to the source location.
### VS Code Embedded Commands for Testing
### VS Code testing commands
<p align="center">
<img src="images/java-testing/command_palette.png" alt="VS Code Embedded Commands for Testing"/>
</p>
There are other testing commands (for example, **Run Tests in Current File**) that can be found by searching for 'Test:' in the Command Palette (`kb(workbench.action.showCommands)`).
There are other VS Code embedded commands for testing, which can be found by searching `Test:` in the Command Palette.
![Testing commands in the Command Palette](images/java-testing/command_palette.png)
## Settings
@ -100,32 +86,36 @@ There are other VS Code embedded commands for testing, which can be found by sea
| `java.test.config` | Specify the configuration for the test cases to run with. [More details](https://aka.ms/java-test-config). | `{}` |
| `java.test.defaultConfig` | Specify the name of the default test configuration. | `""` |
### VS Code Embedded Settings for Testing
### VS Code testing settings
<p align="center">
<img src="images/java-testing/settings.png" alt="VS Code Embedded Settings for Testing"/>
</p>
There are VS Code settings specific to testing that can be found by searching for `testing` in the Settings editor (`kb(workbench.action.openSettings)`).
![Testing settings in the Settings editor](images/java-testing/settings.png)
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](https://junit.org/junit5/docs/current/user-guide/#overview-getting-started) from the JUnit 5's official document for getting started documentation.
Please refer to [Getting Started](https://junit.org/junit5/docs/current/user-guide/#overview-getting-started) from the JUnit 5's official website for getting started documentation.
> Note: If your project does not use build tools(Maven/Gradle/...), please make sure [junit-platform-console-standalone.jar](https://search.maven.org/search?q=g:org.junit.platform%20AND%20a:junit-platform-console-standalone) is on your project classpath.
> Note: If your project does not use build tools (Maven/Gradle/...), make sure [junit-platform-console-standalone.jar](https://search.maven.org/search?q=g:org.junit.platform%20AND%20a:junit-platform-console-standalone) is on your project classpath.
### JUnit 4
Please refer to [Download and Install](https://github.com/junit-team/junit4/wiki/Download-and-Install) from the JUnit 4's official document for the getting started documentation.
Refer to [Download and Install](https://github.com/junit-team/junit4/wiki/Download-and-Install) from the JUnit 4's official website for the getting started documentation.
### TestNG
Please refer to [TestNG Docs](https://testng.org/doc/) from the TestNG's official document for getting started documentation.
Refer to the [Welcome documentation](https://testng.org/doc/) from the TestNG official website for getting started information.
## FAQ
If you meet any problem when using the extension, please refer to the [FAQ](https://github.com/microsoft/vscode-java-test/wiki/FAQ) and our [issue list](https://github.com/microsoft/vscode-java-test/issues) to check if there is an answer to your problem.
If you meet any problem when using the extension, you can review the [FAQ](https://github.com/microsoft/vscode-java-test/wiki/FAQ) and our [issue list](https://github.com/microsoft/vscode-java-test/issues) 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](https://github.com/Microsoft/vscode-java-test/blob/main/CONTRIBUTING.md), which covers the following parts:
- [Questions and Feedback](https://github.com/Microsoft/vscode-java-test/blob/main/CONTRIBUTING.md#questions-and-feedback)
- [Reporting Issues](https://github.com/Microsoft/vscode-java-test/blob/main/CONTRIBUTING.md#reporting-issues)
- [Contributing Fixes](https://github.com/Microsoft/vscode-java-test/blob/main/CONTRIBUTING.md#contributing-fixes)