Support for "related code" in tests
See original GitHub issue@connor4312 Is there any consideration to how I would present one or more tests as being related to a code item like a function?
For instance, in Pester you can tag tests with anything. If I allowed a special tag that let you say a test was assigned to a certain function named Invoke-MyFunction
, I’d want to expose a “play” button right next to the Invoke-MyFunction
definition to run all tests “tagged” to that function. In this case though I don’t want it to be tracked with a separate ID, I want it to invoke those individual tests as part of the tag “rollup” which might be scattered across different files. Also tricky is how you would present a failure to the user in this case.
Ideally this would work with AutoRun as well whenever I change the function.
At any rate this is definitely a “nice to have” as opposed to a “must have” and could come at a later iteration, just a thought that would make testing really simple for people and not have to lose the context of where they are directly working on the application. I was inspired by your markdown test adapter example.
With the existing implementation it could just be offered under a “Function Test Rollup” header or something and aggregate the results together somehow, but when run it wouldn’t update the “referenced” tests necessarily (though I guess I could do this within the context of the extension) so its fragmented and not ideal.
_Originally posted by @JustinGrote in https://github.com/microsoft/vscode/issues/107467#issuecomment-861177620_
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:22 (13 by maintainers)
Top GitHub Comments
Thanks for the feedback, all.
From feedback, I think one approach we can take is, like we do on tests, something of a hybrid:
relatedCode?: vscode.Location[]
on theTestItem
.URI
).provideImplementations(testItem: vscode.TestItem): ProviderResult<vscode.Location[]>
/provideAssociatedTests(location: vscode.Location): ProviderResult<vscode.TestItem[]>
methods to be added to the TestController.relatedCode?
property. These should return ranges and test items rather than adding to therelatedCode
property, since the relations are point-in-time and should not be persisted and tracked like theTestItem
property.cc @jdneo / @kimadeline / @JustinGrote
Same in Java, lots of Java developers tends to append
Test(s)
at the end of the class name. But that’s not part of the Java spec. The handler approach can let us do some ‘guess’ action to find the related test code.