How to invoke MsTestV2 unit test programmatically
saiparth opened this issue · comments
I am using specflow with MsTestV2.
Due to unavoidable reasons, I would like to trigger this unit test programmatically. Where i can find details for this?
What do you mean? Can you explain it a bit more, and maybe provide us an example?
If you like preserve the entire test platform you can execute the test via https://github.com/microsoft/vstest/blob/master/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs class. A sample usage is in our integration tests. (https://github.com/microsoft/vstest/blob/master/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs)
I have kept all test name in a xml, will read that as a list and invoke one by one. So I dint use console runner.
@Haplois
https://github.com/microsoft/testfx/blob/master/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestExecutorTests.cs
Can this be used?Is there any other example? Since its using mock I am not able to write test properly.
@saiparth
I have kept all test name in a xml, will read that as a list and invoke one by one. So I dint use console runner.
VsTestConsoleWrapper
has a method to run tests one by one as well.
@Haplois
https://github.com/microsoft/testfx/blob/master/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestExecutorTests.cs
Can this be used?Is there any other example? Since its using mock I am not able to write test properly.
No it cannot, it's mocking the actual process, tests might not be run properly. Please check our E2E tests; this example might be useful, be we recommend to use VsTestConsoleWrapper
.