Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Adopt to the new VS Code tests API #1257

Merged
merged 22 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b25e099
initialize the repo (#1237)
jdneo Jul 27, 2021
93f01d7
Add command to list Java projects (#1238)
jdneo Jul 28, 2021
eda2f32
Add load project logic at client side (#1239)
jdneo Jul 28, 2021
eb1c3c5
List packages and classes at server side (#1240)
jdneo Jul 28, 2021
53515e0
Support list package at client side (#1241)
jdneo Jul 28, 2021
155611a
List children of a class (#1242)
jdneo Jul 28, 2021
21cf7f3
List test classes & methods in a file (#1243)
jdneo Jul 29, 2021
f453aa8
Watch the workspace changes at client (#1244)
jdneo Jul 29, 2021
2c041d6
Update test items when document changes (#1246)
jdneo Aug 2, 2021
0a2df26
Resolve launch parameters for test runner (#1247)
jdneo Aug 2, 2021
090802c
Run test from controller (#1248)
jdneo Aug 2, 2021
175934d
Support find test location from full name (#1249)
jdneo Aug 2, 2021
3eebaee
Adopt new testing apis for all the runners (#1250)
jdneo Aug 2, 2021
2ca4ab9
Can open stacktrace (#1251)
jdneo Aug 2, 2021
732da97
Add commands to the test explorer (#1252)
jdneo Aug 2, 2021
257d92c
Add commands for the Java project explorer (#1253)
jdneo Aug 2, 2021
ff71460
Update the document (#1254)
jdneo Aug 3, 2021
f3c0afd
Add changelog (#1255)
jdneo Aug 3, 2021
d23b06c
Can navigate to source from TestNG's stacktrace (#1256)
jdneo Aug 3, 2021
a9414f3
Disable the test since we now does not have cases
jdneo Aug 3, 2021
d14e4c8
Merge branch 'cs/1.0.0-feature' of https://github.com/microsoft/vscod…
jdneo Aug 3, 2021
5d81923
Correct the branch name
jdneo Aug 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
- name: Build OSGi bundle
run: npm run build-plugin

- name: Test extension
run: DISPLAY=:99 npm test
# - name: Test extension
# run: DISPLAY=:99 npm test

- name: Print language server Log if job failed
if: ${{ failure() }}
Expand Down Expand Up @@ -107,8 +107,8 @@ jobs:
- name: Build OSGi bundle
run: npm run build-plugin

- name: Test extension
run: npm test
# - name: Test extension
# run: npm test

- name: Print language server Log if job failed
if: ${{ failure() }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ resources/templates/css/**
resources/templates/js/**
resources/templates/fonts/**
dist
**/vscode.d.ts
**/vscode.proposed.d.ts
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the "vscode-java-test" extension will be documented in th
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.31.0
### Changed
- Adopted new [VS Code testing API](https://github.com/microsoft/vscode/issues/107467). For more details, please refer to the [README page](https://github.com/microsoft/vscode-java-test/blob/main/README.md).

## 0.30.1
### Fixed
- [Bugs fixed](https://github.com/microsoft/vscode-java-test/issues?q=is%3Aissue+is%3Aclosed+label%3Abug+milestone%3A0.30.1)
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ If you are interested in writing code to fix issues, please check the following
### Overview
The extension has three major modules, which are listed as follow:
- The extension client written in TypeScript - UI logic mostly
- [The Java Test Plugin](https://github.com/Microsoft/vscode-java-test/tree/master/java-extension/com.microsoft.java.test.plugin) written in Java - Inspect the Java project
- [The Java Test Runner](https://github.com/Microsoft/vscode-java-test/tree/master/java-extension/com.microsoft.java.test.runner) written in Java - An executable jar to running the test cases
- [The Java Test Plugin](https://github.com/Microsoft/vscode-java-test/tree/main/java-extension/com.microsoft.java.test.plugin) written in Java - Inspect the Java project
- [The Java Test Runner](https://github.com/Microsoft/vscode-java-test/tree/main/java-extension/com.microsoft.java.test.runner) written in Java - An executable jar to running the test cases

### Setup
1. Fork and clone the repository: `git clone git@github.com:Microsoft/vscode-java-test.git`
Expand All @@ -52,7 +52,7 @@ The extension has three major modules, which are listed as follow:
### Debugging
1. Hit `F5` (or run `Launch Extension` in the debug viewlet) to launch the extension in debug mode
> This will open a new VS Code window as a debug session. Open a Java project folder and let the extension be activated, then you can debug it.
2. If you want to debug the Java Test Plugin, run [Debug Test Runner Java Plugin (Attach)](https://github.com/microsoft/vscode-java-test/blob/master/.vscode/launch.json) in the debug viewlet.
2. If you want to debug the Java Test Plugin, run [Debug Test Runner Java Plugin (Attach)](https://github.com/microsoft/vscode-java-test/blob/main/.vscode/launch.json) in the debug viewlet.

> Note: If the Java code is changed by you, please run `npm run build-plugin` before you start debugging, the output jars will be generated in the folder `server/`.
Expand Down
96 changes: 44 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
> Run and debug Java test cases in Visual Studio Code

<p align="center">
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/master/resources/logo.png" width="128" height="128" alt="">
<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?query=workflow%3ACI+branch%3Amaster">
<img src="https://img.shields.io/github/workflow/status/microsoft/vscode-java-test/CI/master?style=flat-square" alt="">
<a href="https://github.com/microsoft/vscode-java-test/actions?query=workflow%3ACI+branch%3Amain">
<img src="https://img.shields.io/github/workflow/status/microsoft/vscode-java-test/CI/main?style=flat-square" alt="">
</a>
<a href="https://lgtm.com/projects/g/microsoft/vscode-java-test/alerts/?mode=list">
<img src="https://img.shields.io/lgtm/alerts/g/microsoft/vscode-java-test.svg?style=flat-square" alt="">
Expand Down Expand Up @@ -36,108 +36,100 @@ The [Java Test Runner](https://marketplace.visualstudio.com/items?itemName=vscja
- Customize test configurations
- View test report
- View tests in Test Explorer
- Show test logs


## Requirements

- JDK (version 11 or later)
- VS Code (version 1.44.0 or later)
- VS Code (version 1.59.0 or later)
- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java)
- [Debugger for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug)

## Quickstart

![Run/debug JUnit test](demo/demo.gif)

### Getting Started for 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 guide.

> Note: You can use [junit-platform-console-standalone.jar](https://search.maven.org/search?q=g:org.junit.platform%20AND%20a:junit-platform-console-standalone) in projects that manually manage their dependencies similar to the [plain-old JAR known from JUnit 4](https://github.com/junit-team/junit4/wiki/Download-and-Install#plain-old-jar).

### Getting Started for 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 guide.

### Getting Started for TestNG

Please refer to [TestNG Docs](https://testng.org/doc/) from the TestNG's official document for getting started guide.

## Features

### Run/Debug Test Cases
<p align="center">
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/master/demo/run_codelens.png" style="border-radius: 15px" alt="Run Code Lens"/>
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/editor-decoration.png" alt="Run/Debug Test Cases"/>
</p>

- 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](https://github.com/Microsoft/vscode-java-test/issues/470#issuecomment-444681714) as a workaround.
- 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.

---

### Test Explorer

<p align="center">
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/master/demo/run_explorer.png" style="border-radius: 15px" alt="Run Explorer"/>
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/test_explorer.png" alt="Test Explorer"/>
</p>

- 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](https://github.com/Microsoft/vscode-java-test/issues/470#issuecomment-444681714) as a workaround.
- 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.

---

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

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

> Note: More details can be found [here](https://github.com/Microsoft/vscode-java-test/wiki/Run-with-Configuration).

---

### View Test Report
### View Test Result

<p align="center">
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/master/demo/status_bar.png" style="border-radius: 15px" alt="Status Bar"/>
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/test_report.png" alt="View Test Result"/>
</p>

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

### VS Code Embedded Commands for Testing

<p align="center">
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/master/demo/report_navigate.png" style="border-radius: 15px" alt="Status Bar"/>
<img src="https://raw.githubusercontent.com/Microsoft/vscode-java-test/main/demo/command_palette.png" alt="VS Code Embedded Commands for Testing"/>
</p>

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

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

## 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](https://aka.ms/java-test-config). | `{}` |
| `java.test.defaultConfig` | Specify 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](https://junit.org/junit5/docs/current/user-guide/#overview-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](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.

### TestNG
Please refer to [TestNG Docs](https://testng.org/doc/) 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](https://github.com/microsoft/vscode-java-test/wiki/FAQ) to check if there is an answer to your problem.
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.

## 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/master/CONTRIBUTING.md), which covers the following parts:
- [Questions and Feedback](https://github.com/Microsoft/vscode-java-test/blob/master/CONTRIBUTING.md#questions-and-feedback)
- [Reporting Issues](https://github.com/Microsoft/vscode-java-test/blob/master/CONTRIBUTING.md#reporting-issues)
- [Contributing Fixes](https://github.com/Microsoft/vscode-java-test/blob/master/CONTRIBUTING.md#contributing-fixes)
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)

## License

Expand Down
Binary file added demo/command_palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed demo/demo.gif
Binary file not shown.
Binary file added demo/editor-decoration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed demo/report_navigate.png
Binary file not shown.
Binary file removed demo/run_codelens.png
Binary file not shown.
Binary file removed demo/run_explorer.png
Binary file not shown.
Binary file added demo/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed demo/status_bar.png
Binary file not shown.
Binary file added demo/test_explorer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/test_report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions extension.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,4 @@
// Licensed under the MIT license.

export { activate, deactivate } from './src/extension';
export * from './src/codelens/TestCodeLensProvider';
export * from './src/codelens/TestCodeLensController';
export * from './src/runners/models';
export * from './src/testResultManager';
export * from './src/protocols';
export * from './src/utils/commandUtils';
export * from './src/testFileWatcher';
export * from './src/runners/runnerScheduler';
export * from './src/provider/testSourceProvider';
20 changes: 0 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
const gulp = require('gulp');
const cp = require('child_process');
const tslint = require('gulp-tslint');
const sass = require('gulp-sass')(require('sass'));
const path = require('path');
const fs = require('fs');
const remoteSrc = require('gulp-remote-src');

const serverDir = path.join(__dirname, 'java-extension');
const resourceDir = path.join(__dirname, 'resources');
Expand Down Expand Up @@ -54,24 +52,6 @@ gulp.task('tslint', (done) => {

gulp.task('lint', gulp.series('tslint'));

// Test report resources
gulp.task('sass', (done) => {
gulp.src(['resources/templates/scss/*.scss'])
.pipe(sass())
.pipe(gulp.dest('resources/templates/css'));
done();
});

gulp.task('download-resources', (done) => {
remoteSrc(['jquery-3.5.1.slim.min.js'], { base: 'https://code.jquery.com/' })
.pipe(gulp.dest(path.join(resourceDir, 'templates', 'js')));
remoteSrc(['bootstrap.bundle.min.js'], { base: 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/' })
.pipe(gulp.dest(path.join(resourceDir, 'templates', 'js')));
done();
});

gulp.task('build-resources', gulp.series('sass', 'download-resources'));

function isWin() {
return /^win/.test(process.platform);
}
Expand Down
2 changes: 1 addition & 1 deletion java-extension/build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.java.test</groupId>
<artifactId>parent</artifactId>
<version>0.30.1</version>
<version>0.31.0</version>
</parent>
<groupId>com.microsoft.java.test</groupId>
<artifactId>test-runner-build-tools</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
<bundle id="com.microsoft.java.test.plugin" version="0.30.1"/>
<bundle id="com.microsoft.java.test.plugin" version="0.31.0"/>
</site>
2 changes: 1 addition & 1 deletion java-extension/com.microsoft.java.test.plugin.site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.microsoft.java.test</groupId>
<version>0.30.1</version>
<version>0.31.0</version>
</parent>
<artifactId>com.microsoft.java.test.plugin.site</artifactId>
<packaging>eclipse-repository</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.microsoft.java.test.plugin
Bundle-SymbolicName: com.microsoft.java.test.plugin;singleton:=true
Bundle-Version: 0.30.1
Bundle-Version: 0.31.0
Bundle-Activator: com.microsoft.java.test.plugin.util.JUnitPlugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.jdt.core,
Expand Down
9 changes: 5 additions & 4 deletions java-extension/com.microsoft.java.test.plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
<extension point="org.eclipse.jdt.ls.core.delegateCommandHandler">
<delegateCommandHandler class="com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler">
<command id="vscode.java.test.get.testpath" />
<command id="vscode.java.test.search.items" />
<command id="vscode.java.test.search.items.all" />
<command id="vscode.java.test.search.codelens" />
<command id="vscode.java.test.search.location" />
<command id="vscode.java.test.junit.argument" />
<command id="vscode.java.test.generateTests" />
<command id="vscode.java.test.findJavaProjects" />
<command id="vscode.java.test.findTestPackagesAndTypes" />
<command id="vscode.java.test.findDirectTestChildrenForClass" />
<command id="vscode.java.test.findTestTypesAndMethods" />
<command id="vscode.java.test.resolvePath" />
</delegateCommandHandler>
</extension>
</plugin>
2 changes: 1 addition & 1 deletion java-extension/com.microsoft.java.test.plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.microsoft.java.test</groupId>
<artifactId>parent</artifactId>
<version>0.30.1</version>
<version>0.31.0</version>
</parent>
<artifactId>com.microsoft.java.test.plugin</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
Loading