-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Testing API finalization #122208
Comments
Feature request:
How I imagine:
The actual: |
Test items have a |
When |
Okay thats something but one point users might wanna do filtering by tags. In that case if I only use it as a string in the description:
Well I didn't go to details. I'm just hoping it's clear. Let me know if you need clarification. It would be a nice feature I believe. Question: when can I modify the error, label, description, etc fields? Will they be reflected automatically? |
Does the |
Yes
It simplifies things. We didn't find many use cases where the URI would change without tests being recreated/re-read |
Here is one but I would say pretty rear: User moves tests from test1.cpp to test2.cpp which are bundled to the same executable. after recompilation the URI will change of course. With the current API I have to check the URI too and if there is a need for update I have to dispose and recreate. It's not a biggie though just for the record. How about my previous question: What if I don't have URI? What should I pass? Null? |
URIs are required on all tests. If you don't have a specific file, you can pass in the URI to a relevant directory instead. |
Even if the only relevant I can figure out is the workspaceFolder itself? How will that effect the UX? |
Well, if you have no location for a test we will not be able to show things like editor decorations, "go to test" will not work, etc -- essentially you'll only get the overview of tests in the test explorer view, and little else. The experience is significantly less useful without having URIs for tests. This is not a common scenario and not something that I want to go out of the way to design for. |
Okay. As I said it is a really valid situation/use-case when I won't have URI.
|
The URI is now optional |
Thanks, fixed
This uses the default VS Code hover, please open a separate issue for that!
Yes |
Created #123927. BTW, where can I see the test execution duration in the UI? (Maybe I missed somewhere) |
Currently test execution duration isn't shown, but it will be soon. |
Duration will be shown in the test explorer view as of the next Insiders |
Will this make it into 1.57? I'm assuming we could start shipping our extensions with https://marketplace.visualstudio.com/items?itemName=ms-vscode.test-adapter-converter then? |
Was able to update without much issue, but this runhandler conversion hurts my brain so much. Did this instead:
Also this API is so much cleaner now, thank you! const testWatcher = workspace.createFileSystemWatcher(pattern)
const tests = this.testController.items
testWatcher.onDidCreate(uri => tests.add(TestFile.getOrCreate(testController, uri)))
testWatcher.onDidDelete(uri => tests.delete(uri.toString()))
testWatcher.onDidChange(uri => this.testController.resolveChildrenHandler!(TestFile.getOrCreate(testController, uri))) |
@JustinGrote Insiders doesn't get released on Friday nights, it'll be out Monday morning. I did that just to force you to learn more js/ts 😉 It provided a minimal conversion, though higher order functions are more common in client-side code. Thanks for the feedback on runnability. I'm considering something like this, but will continue to think it over:
So for example you could have a custom "runnable" tag not present on subtests, and the presented Go scenario could have a "runnable-darwin" tag to indicate a test only runnable on a certain platform/under certain configurations. interface TestRunProfile {
tag?: TestTag;
// ...
}
interface TestItem {
tags?: readonly TestTag[];
// ...
}
class TestTag {
readonly id: string;
// maybe more things like a label later, if this is ever exposed in UI
} |
@connor4312 That would work for me. |
As we near the end of the iteration, the the test APIs we intend to finalize have been moved to this section (ctrl+f for 122208 if this moves from additional changes in the file): https://github.com/microsoft/vscode/blob/main/src/vs/vscode.proposed.d.ts#L1972. Notably, invalidation is not being finalized. We implemented invalidation and autorun since the Test Explorer UI did so, but autorun is something that most test runners can handle themselves very efficiently, so I would like to remove the notion invalidation and create some mechanism to give extensions control over auto-run instead. Additionally there were a few changes today, mostly renames:
Example of a migration: microsoft/vscode-test-adapter-converter@6805807 |
@connor4312 For Go, I append a message for all test output that can be linked to a specific file. That means, output of the form |
@connor4312, is there anyway to quickly get the size of the Background: when a test item needs to be removed, and its parent has no other children, I want to remove its parent as well. |
The question we're having is about the relation of |
We discussed this in our call this morning. We're looking at changing the TestRunResult to remove export interface TestRun {
enqueued(test: TestItem): void;
started(test: TestItem): void;
skipped(test: TestItem): void;
failed(test: TestItem, message: TestMessage | TestMessage[], duration?: number): void;
passed(test: TestItem, duration?: number): void; This is similar to notebook cell execution. In this scenario, TestMessages are tied only to a test failure, and are given only to tests that fail. We propose for next month adding an optional test to associate export interface TestRun {
appendOutput(output: string, test?: TestItem): void; This allows diagnostic log output to associated with a test, regardless of its passed or failed state. This also gets rid of the weird possible state of having "error" TestMessages for tests that pass. Please let me know what you think of this proposal. I plan to implement it this afternoon pending feedback, and this plus one more small rename is the only outstanding change we have for finalization at this time. |
@connor4312 if I understand your proposal correctly, wondering If the purpose of splitting
typescript will enforce the proper arguments while the API can consolidate multiple API into 1, IMHO, more intuitive |
@connor4312 I want to attach output to a specific location, as in the For more context: When I am running tests to debug a function, I often use Go's test logging facilities to give me more information. This isn't a great example (and I've removed most of the cases for clarity), but here's a screenshot of how it works with If I introduce an error, with the previous API this is what I see: I want to retain this. That is, I want to be able to log non-error output that is attached to a specific location (and test), as well as error output that is attached to a location. I like the idea of message severity, and I can imagine reasons for wanting to log warning messages that do not cause the test to fail. But even if you kept that, I'm unlikely to support anything other than Info and Error, due to limitations of Go. Personally, I prefer Side note: the UX isn't great when a bunch of test messages are stacked on top of each other: I would prefer to see all the messages for a given location during a given test run grouped together. I can do this myself in the extension, but I wonder how much utility there is in listing each message individually. |
Thanks for the feedback. Yea, the notion of stacked test messages in the peek is not particularly attractive or intuitive. That was another potential distinction we discussed when considering messages that indicate failure versus general log messages. I'll create an issue for message discussion separately from this issue. The decoration you showed in your first screenshot is an attractive experience that I'm interested in preserving to some degree, but I don't know what that will look like yet. The aforementioned changes have now been made:
Also, the Example migration: microsoft/vscode-extension-samples@1748ee9 |
@connor4312 Is this something that can be tested in stable VSCode by setting |
We only ship stable ~once per month, so the latest set of API changes will not be in stable, you can only test the old API. The next stable release where these changes are included should arrive when this comment is two weeks old. |
@connor4312 Is there any replacement for |
Would setting |
@connor4312 got a chance to implement today, conversion wasn't too bad. I did have rewrite my "tree walker" function to find all the tests included when a "header" parent testitem is run, I really feel this is something that should be part of the API of |
@connor4312 That's better than nothing, but I preferred the previous UX. It showed |
For anyone else who struggled with the recursive stuff, here's my helper function /** Runs the specified function on this item and all its children, if present */
async function forAll(parent: TestItem, fn: (child: TestItem) => void) {
fn(parent)
parent.children.forEach((child) => {
forAll(child, fn)
})
}
//Example use to set all test results to running
forAll(testParentItem, run.success) |
echo to @firelizzard18. Differentiate The test can be failed due to:
BTW, since the TestResultState has |
Okay, I'll bring errored back (as another method on the TestRun). Thanks for the feedback! |
@connor4312 the thing I'm most struggling with right now is correlating the tests in the controller with the tests that come back from my adapter. I've been using the id string as a global unique identifier, but now that is only unique to a given Here are the util functions I made to handle this, they would be better if testItemCollection had an |
Separating from #107467 to have a focused issue. These APIs will be finalized (ctrl+f for 122208 if this moves from additional changes in the file): https://github.com/microsoft/vscode/blob/main/src/vs/vscode.proposed.d.ts#L1972
The text was updated successfully, but these errors were encountered: