-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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 API Feedback #127143
Comments
Yea. Or, in another common case that every extension hits, the user reloads the window. If we use object identity, we have no way to re-associated the results. In the initial API, before I had ID's, I used a "path of labels" but this was just a less well-specified ID, so I changed that. Is modelling it more explicitly done by having a custom string type with documentation as you suggested in PM, or are you thinking of something more here?
To me it reads better as
This is somewhat tricky right now. In the current API, items have an unchanging parent from the moment of their creation. With an array of items, we give that control over to extensions, so items could have multiple parents, change parents, or duplicated within an array. These are errors we could check against and throw at runtime, but they're also errors which it's not possible to make in the current set of APIs. (I think we could actually deal with changing parents pretty easily internally by deleting and re-creating the item, but allowing multiple parents would be a large change for dubious benefit.) That said I see how
It is slightly special in that disposing it is invalid, but I think its utility outweighs its specialness:
|
FWIW I'm much happier with the API now that "data" was moved out to a separate optional mapping implementation and all the generics can be pulled out. I like that TestItem interface is now a "catchall" for any test tree item, and I can define any "metadata" I need for a test in my separately managed data object (or dynamically pulled, whatever I want). It should always be just that, a conduit/representation of an object in the UI, and not dictate to me how I run my tests or how I gather the data for my tests. If it were broken out by the vscode API into suites, groups, etc. then you are dictating to me how I organize my tests. Also now that all discovery and run is funneled through the controller, I can choose if I want to define the logic then and there, or if I want to shunt the logic out to my little metadata object that represents the test, there's more freedom there. I agree I think the root is fine and having it be a test item means my interface or unions don't have to include some other "random" type. I think #127096 is valid, however today that could be controlled by extension settings or an extension contributed "options" window with checkboxes and whatnot, though that interface should probably be standardized to the Test API, maybe a dropdown where additional configurations can be supplied by the extension similar to how the Debug dropdown works. |
I added a proposal in here which you might like: #127096 (comment) |
In a way we wouldn't care too much. For us, only the assignment to // used to represent a "snapshot" like suites and tests for a certain document version
interface TestItem {
id: string;
location: Uri | Location;
label: string;
children?: TestItem[];
// more...
}
// managed object with lifecycle, like a file
interface TestContainer {
dispose(): void;
readonly id: string;
readonly uri: Uri | undefined;
// get/set to update test items
items: TestItem[]
// more...
}
function createTestContainer(id: string): TestContainer
interface TestController {
// get/set
tests: TestContainer[]
} For me the appeal is in the simplicity for extensions: a test container would represent a "source of truth" like a file or live document and extensions can simply extract data from them and set it onto the corresponding container. No need for cleanup or object updates |
I don't actually know. There is one part that makes me think test id are like uris and then they would deserve a type. And that type should be used. However, they are also different because they only allow for identification, but not locating, of items. Looking at the use-cases you have listed I wonder how mandatory the id is or if something like a version id is missing (this touches on |
I like that too but I don't like |
re #122208
This is a bit of a potpourri of API feedback regarding testing. Some are nit, some are about "firsts" 🥇, but also some bigger concerns 💭.
💭 Lacking "Run Options/Configs"
Two things have been modeled so far: "runnable" and "debuggable" (via
TestItem#{runnable,debuggable}
andTestRunRequest#debug
). However, there is no notion of "run in safari" (playwright, vscode-selfhost use-case), "run with coverage", "run and profile" etc. As far as the UI is concerned we want to show commands and the flexible alternative is commands, menus, and context keys.This concerned has been shelled out to #127096
💭 TestItem#id
A test item needs to have a unique identifier. It is not clear what this is used for because the id isn't "referenced" anywhere, instead the
TestItem
is used. E.g test results are collected by item instance ((TestRun#setState
), not by id. The same for appendMessage etc. My understanding is that I can dispose a test item and re-create it with the same id and its results are kept (re-associated). Assuming that's correct, it should be modeled more explicit. Also, todays design makes me wonder why there isn't justTestItem.setState(runRequest, runResult)
, esp. in the presence ofTestItem#invalidateResults
?💭 TestItems everywhere
TestItem is a recursive and lazy data structure that represents everything: file, suite, test etc. I understand the desire for lazy test containers, like files, but I doubt the usefulness for recursive laziness. Like, you can identify something as containing suites and tests and analyzing that something will take time but I doubt that the analysis itself will be lazy. My dummy extension does the following (and I bet non-sample extensions do the same):
This feels cumbersome and I assume it is also why recursive disposal of test items was "invented". I would prefer a simple setter on a managed container object, like
testContainer.items = [pojoTestItem1, pojoTestItem2]
. I also doubt that any extension manages and updates existing items. Sample: when inserting a newline in a test file each item must get a newrange
property. Unless the test items are kept as AST-like incremental data structure it will all be "fake"; meaning some process (reflection, ast-traversal, execution) produces a set of new items and we now ask extensions to do the diffing. It is much more friendly when extensions can "throw new items over the fence" and VS Code does the diffing (e.g by test item id)🥇 Firsts
children
is a justified "first case" and wonder what we loose ifreadonly TestItem[]
is used. What would be the recommendation for furture map vs iterable vs array questions and what should happen to existing APIs?TestController#root is not a test item
That smells like implementation detail making it to the API... I don't even wanna think about
TestController#root.dispose()
orTestRun.setState(ctrl.root, ...)
The text was updated successfully, but these errors were encountered: