-
Notifications
You must be signed in to change notification settings - Fork 34.8k
Description
Refs: #107467
Complexity: 5
Authors: @connor4312
As part of testing, we have an API that allows extensions to read and publish test results. Namely:
vscode/src/vs/vscode.proposed.d.ts
Lines 2157 to 2182 in eff172b
/** | |
* Inserts custom test results into the VS Code UI. The results are | |
* inserted and sorted based off the `completedAt` timestamp. If the | |
* results are being read from a file, for example, the `completedAt` | |
* time should generally be the modified time of the file if not more | |
* specific time is available. | |
* | |
* This will no-op if the inserted results are deeply equal to an | |
* existing result. | |
* | |
* @param results test results | |
* @param persist whether the test results should be saved by VS Code | |
* and persisted across reloads. Defaults to true. | |
*/ | |
export function publishTestResult(results: TestResults, persist?: boolean): void; | |
/** | |
* List of test results stored by VS Code, sorted in descnding | |
* order by their `completedAt` time. | |
*/ | |
export const testResults: ReadonlyArray<TestResults>; | |
/** | |
* Event that fires when the {@link testResults} array is updated. | |
*/ | |
export const onDidChangeTestResults: Event<void>; |
The intention is for this API to be useful if, for example:
- An extension can
publishTestResults
that it reads test results off the disk - An extension can
publishTestResults
if it detects that tests results were run outside of theTestProvider.runTests
API - An extension can react to test passes or failures
Note that test results are associated with the "living" test items through their ID, so if you publish a test result for a test that a provider isn't providing anywhere, you won't see any UI for it.
Please build an extension to give these APIs and shot and let me know how it goes! For example you might build an extension that pops a toast notification if tests fail or lets the user open test results from a well-known format off disk. Let me know if you run into any problems or ambiguities while doing so.
You might find the sample test provider useful as a foundation to build against, or the more complex selfhost test provider if you feel ambitious.