microsoft / testfx-docs

Docs for MSTest V2 test framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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?

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.