Commit Graph

13 Commits

Author SHA1 Message Date
Simon McEnlly
cf8adf0281 testing: add new API sortText property to TestItem; if populated will be used instead of label for sorting items in Test Explorer tree and list view 2021-09-02 14:45:41 +10:00
Connor Peet
03504d625a testing: support for test tags in search
This also involves creating a suggest enabled input with history, which
I modelled off the previous plain text input with history.
2021-08-12 17:16:32 -07:00
Connor Peet
9125758184 testing: add support for test tags
For #129456
2021-08-09 16:31:23 -07:00
Connor Peet
38e09192c0 testing: api feedback 2021-07-21 15:20:12 -07:00
Connor Peet
cfc48e81aa testing: update api from feedback 2021-07-20 15:02:21 -07:00
Connor Peet
3f9af31b25 testing: update test types for feedback 2021-07-19 08:21:26 -07:00
Connor Peet
92f692d4a3 testing: update more nits 2021-07-16 13:18:06 -07:00
Connor Peet
da7d92b8b1 testing: make test ids locally unique, instead of globally unique 2021-07-16 12:51:53 -07:00
Connor Peet
42c268a626 testing: clean up nits
- rename TestController.createRunConfiguration to .createRunProfile, and associated types
- rename TestItemCollection.remove to TestItemCollection.delete
2021-07-16 12:46:59 -07:00
Connor Peet
581ff12c39 testing: improve test children API
This changeset results from the discussion in and fixes #126987.
Migration for these changes should take about 15-20 minutes.

- `createTestItem` no longer takes a parent. Instead, it creates a free-
  floating test item, which can be added as a child of a parent.
- The `TestItem.children` is now a `TestItemCollection`, a set-like
  interface that also allows replacing items (intelligently diffing
	them internally) wholesale. This removes the need for the "generation
	counter" used in samples previously.
- There is no longer a `root` on the test controller, but instead an
  `items` property which is the same `TestItemCollection`
- The `tests` in the `TestRunRequest` has been replaced with an `include`
  property. If undefined, the extension should run all tests. (Since
	there is no longer a root to reference).

Here's some example migrations:

- 3fad3d66c1
- 3aff746316
2021-07-14 18:12:59 -07:00
Connor Peet
6a76c62232 testing: remove data from TestItems
Data was viral and spread generics all over the place. It was also
hard to type correctly and consistently, which ended up in the type
being `any` unless great care was taken.

This removes the `data`. Instead, consumers can use a `WeakMap<TestItem, T>`
to keep data associated with the test item. This is a similar pattern
to what is used to store data about documents and debug sessions, for
example. Here's an example of a migration:

8fdf822985 (diff-2fe3ad6ad19447c57c5db14c5a6ccb5544944494db6b909540d70ea499784b49R9)
2021-06-24 12:02:49 -07:00
Connor Peet
186e565ec0 refactor: update to new testing API
Previously in the testing API, you called `registerTestProvider` with
your own instance of a TestController, and VS Code would request
workspace or document tests. This has been changed: now, you call
`createTestController`, which returns an object, and call
`createTestItem` to insert test nodes under the `controller.root`.

Extensions should generally decide themselves when to publish tests. For
example, when a file is opened in an editor, test extensions will want
to make sure tests for that file are available so that inline
decorations can be shown. This is pretty similar to what the editor
API does in diagnostics.

There is still a `resolveChildrenHandler` on the controller (rather than
the TestItem directly), which you should _set_ if the test extension
supports lazy discovery. Additionally, if you support running tests,
you'll also want a `runHandler` (migrating from the old `runTests` method).

Some of the existing test providers have been updated, you can check
them out here:

- https://github.com/microsoft/vscode-extension-samples/tree/main/test-provider-sample
- https://github.com/microsoft/vscode-selfhost-test-provider

In summary, to update to the new API:

- Call `vscode.test.createTestController` instead of `registerTestController`
- Move the contents of your `runTests` method to `controller.runHandler`
- Move your `TestItem.resolveHandler` to `controller.resolveChildrenHandler`,
  which may involve adding some `instanceof` checks.
- If you lazily discovered tests in `createDocumentTestRoot`, you'll want
  to trigger that logic based on `vscode.workspace.onDidOpenTextDocument`.
- If your test runner can deal with showing locations of unsaved changes,
  listen for `vscode.workspace.onDidChangeTextDocument` to trigger those
  changes in the tree.
2021-06-21 12:14:24 -07:00
Connor Peet
bec017d389 testing: rework discovery side of testing to new apis 2021-04-14 17:10:46 -07:00