Closed kendrahavens closed 4 months ago
@kendrahavens @cltshivash Where are this apis documented? Can I used the inside vsix to work with test objects? (Discover, start tests, get results?)
@luis-cortina We plan to publish a nuget package to make referencing Test Window APIs easy for extension developers. Until this package is published (it may be a month or two looking at our current backlog) you can manually add a reference to this assembly in your Visual Studio install location: <VSInstallDir>/Common7/IDE/CommonExtensions/Microsoft/TestWindow/Microsoft.VisualStudio.TestWindow.Interfaces.dll
@kendrahavens Thanks.
I'm currently using ITestsService, which looks like it will be deprecated in vs2019, to get discovered tests and run them inside an extension. If it's in fact deprecated, which interface should we use to do this moving forward?
Is there any documentation on this APIs? i.e I need to start the test discovery process inside an extension and I don't really know where to look. Any help will be appreciated.
Luis
@luis-cortina : Thanks for letting us know. ITestsService
is indeed something we are planning to replace with a more performant alternative soon. Just so I understand your scenario fully, you need an API to trigger a test run on a filtered set of tests? Can you elaborate please?
If you have an implementation of ITestContainerDiscoverer
triggering the TestContainersUpdated
event should get a discovery going. This blog should help.
@AbhitejJohn how soon are you thinking? I'm thinking about upgrading my extension, but not sure if ITestService will be available at all for vs2019? Te blog post helps, thanks for that.
@luis-cortina : We are actively working on getting this through - Hoping to have it in an update soon. Could you tell us what functionality in ITestsService
is interesting to your extension?
@AbhitejJohn here is what I'm using:
@luis-cortina : Thanks.
So the usage of ITestsService
is essentially to run a specific test - would supplying the test to run through a filter of Full Qualified Name or Outcome be an easier alternative? The GetTestsAsEnumerableAsync
API cycles through all tests in the store which is pretty slow.
As for ITestExplorerServiceContainerDiscoverer
this was meant primarily for Live Unit Testing and was accidentally public in builds of VS 2017. This wouldn't be available anymore unfortunately per the list above. Just to make sure I'm understanding this right - your extension triggers discovery to ensure everything is up to date, gets a set of tests and runs a specific one? INewTestService.RunTests
with a filter, I described above, could do all of this for you - perform a discovery, filters the test you need to run and then runs it.
@AbhitejJohn Yes, that would work. It would be nice that the filter accepts a predicate of ITest (or whatever the new class is to represent a test), this should also allow someway to run multiple tests as well.
The only reason I'm using ITestExplorerServiceContainerDiscoverer
is to kick off the discovery at the beggining of the vsix load, and it won't be needed anymore.
Hi @kendrahavens @AbhitejJohn, VS2019 is out and I'm looking to upgrade my extension to it. Are any of the deprecated apis available or should i wait for the new ones to come out?
@luis-cortina : The deprecated ITestsService
is still available, yes. The new API I've detailed above are part of a larger change that's being stabilized. We will update this thread as soon as that is available in a preview.
APIs, other than the ones marked deprecated above, are removed. So ITestExplorerServiceContainerDiscoverer
wouldn't be available anymore. A solution build triggers discovery as well if that's an option.
@AbhitejJohn Building the solution is not currently triggering discovery. Only opening the Test Explorer window does. Is there a service that can help me do this better?
@luis-cortina : Opening the Test Explorer ensures that a few initialization hooks are in place to trigger discovery on build - we wouldn't want to perform any test related work unless a user expresses interest in testing - one of which is opening the Test Explorer.
@AbhitejJohn Yeah, is there any way I can do the same thing without asking the user to open the Test Explorer Window??
@kendrahavens @AbhitejJohn @cltshivash Any updates on this? I'm looking for some sort of interface to kickstart the test engine without explicitly opening the Test Explorer. Also, any documentation on the Apis that we can use to interact with the testing engine would be great.
@luis-cortina : I haven't been great with github notifications off late. I've logged an issue to track exposing this new API here. We've currently scheduled to preview this for Q2 of 2020 given our other set of priorities. We should be able to review docs as well as part of that effort. Thanks a lot for your feedback and for following up on this.
There is, in general, a need to be able to extend test discovery to different test sources, as well as to have those test results recorded in TFS.
@suehshtri : The test platform adapter extensiblity helps with that - https://github.com/microsoft/vstest-docs/blob/master/RFCs/0004-Adapter-Extensibility.md. Is there a case where this does not work for you?
Fine Code Coverage extension for 2019 was hooking into tests with ITestContainerDiscoverer. Visual Studio 2022 is not working in this manner. Is there a method of obtaining test projects being run and runsettings in Vs 2022 ?
@tonyhallett : Oh we haven't intentionally changed anything for Test Explorer extensibility in VS 2022. Which interface or API are you using that doesn't work the same? On a related note, for code coverage scenarios I'd imagine IRunSettingsService would work better. Here's an example usage of that API: https://github.com/pimterry/chutzpah/blob/a521844899d85c308307e857cfb07df47421e994/VS2012.TestAdapter/ChutzpahMapperSettingsService.cs#L40. It provides a list of test containers that you can condition runsettings on as well.
@AbhitejJohn Thank you for your response and the link. All is ok now. The ITestContainerDiscoverer was not being loaded as it was missing
[Export(TestContainerDiscoverer)]
I thought that this would be sufficient
[Export(ITestContainerDiscoverer)]
The Test Window logic does not require the concrete implementation to be exported. Perhaps there are changes in your extension where an import of TestContainerDiscoverer
is required? MEF logs are usually found under %localappdata%\Microsoft\VisualStudio\
@AbhitejJohn yes that didn't make sense. I will check further. Thanks for log path.
Make the list of APIs listed above for Test Platform side internal instead of public. This should probably be done for 17.5.
This is breaking change to the public api and won't be implemented, we are focusing on adding new features to Testing.Platform instead. https://aka.ms/testingplatform
Visual Studio 2019 Test-related API removal
In previous releases of Visual Studio there were several test-related APIs marked public, but were never documented or intended for external use. With Visual Studio 2019, we plan to deprecate and/or remove the APIs listed in the tables below. We know this could affect extension owners so we are communicating this very early and before the first preview release of Visual Studio 2019.
Only public APIs under Microsoft.VisualStudio.TestWindow.Interfaces.dll will be available to extend.
If this impacts you and your customers please comment so we can better understand your scenario.
Microsoft.VisualStudio.TestPlatform
Microsoft.VisualStudio.TestWindow (under Microsoft.VisualStudio.TestWindow.Interfaces.dll)
Microsoft.VisualStudio.TestWindow
The following APIs not under Microsoft.VisualStudio.TestWindow.Interfaces.dll are amongst the list of APIs removed.