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

Test: test results api #117307

Closed
2 tasks done
connor4312 opened this issue Feb 23, 2021 · 0 comments
Closed
2 tasks done

Test: test results api #117307

connor4312 opened this issue Feb 23, 2021 · 0 comments

Comments

@connor4312
Copy link
Member

connor4312 commented Feb 23, 2021

Refs: #107467

Complexity: 5

Authors: @connor4312

Create Issue


As part of testing, we have an API that allows extensions to read and publish test results. Namely:

/**
* 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 the TestProvider.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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants