|
| 1 | +# Example Test Adapter for Visual Studio Code |
| 2 | + |
| 3 | +This repository contains an example for implementing a `TestAdapter` extension that works with the |
| 4 | +[Test Explorer](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer) extension. |
| 5 | + |
| 6 | +More documentation can be found in the [Test Adapter API repository](https://github.com/hbenl/vscode-test-adapter-api). |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +* install the [Test Explorer](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer) extension |
| 11 | +* fork and clone this repository and open it in VS Code |
| 12 | +* run `npm install` |
| 13 | +* run `npm run watch` or start the watch Task in VS Code |
| 14 | +* start the debugger |
| 15 | + |
| 16 | +You should now see a second VS Code window, the Extension Development Host. |
| 17 | +Open a folder in this window and click the "Test" icon in the Activity bar. |
| 18 | +Now you should see the fake example test suite in the side panel: |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +## Basic implementation |
| 23 | + |
| 24 | +* add any configuration properties that your Test Adapter needs to the `contributes.configuration.properties` section of `package.json` |
| 25 | +* replace the `loadFakeTests()` call in `src/adapter.ts` with your code for loading the test definitions for the real test framework |
| 26 | +* replace the `runFakeTests()` call in `src/adapter.ts` with your code for running the tests in a child process using the real test framework |
| 27 | + |
| 28 | +## Getting ready to publish |
| 29 | + |
| 30 | +* search for all occurrences of the word "example" in this project and replace them with the name of the testing framework that your Test Adapter supports |
| 31 | +* update `package.json` with your preferred values (at a minimum you should change `author`, `publisher`, `homepage`, `repository` and `bugs`) |
| 32 | +* create an icon for your Test Adapter (there's an SVG version of the Test Explorer icon at `img/test-explorer.svg`) and reference it in `package.json` |
| 33 | +* replace this README with your documentation |
| 34 | + |
| 35 | +Now you're ready to [publish](https://code.visualstudio.com/docs/extensions/publish-extension) the first version of your Test Adapter. |
| 36 | + |
| 37 | +## Completing the implementation |
| 38 | + |
| 39 | +* implement the `debug()` method |
| 40 | +* implement the `cancel()` method (it should kill the child process that was started by `run()` or `debug()`) |
| 41 | +* watch the configuration for any changes that may affect the loading of test definitions and reload the test definitions if necessary |
| 42 | +* watch the workspace for any changes to the test files and reload the test definitions if necessary |
| 43 | +* watch the configuration for any changes that may affect the results of running the tests and emit an `autorun` event if necessary |
| 44 | +* watch the workspace for any changes to the source files and emit an `autorun` event if necessary |
| 45 | +* ensure that only one test run is active at a time |
0 commit comments