How to run a single test case from MSTEST

与世无争的帅哥 提交于 2019-12-06 19:00:23

问题


I am using MStest to run a single test case but could not find a correct command

I tried:

1)mstest.exe /testcontainer:testproject.dll /test:MethodTest1 This run all the test case starting from name MethodTest1. I have other test name Like MethodTest100, MethodTest101

2)mstest.exe /testcontainer:testproject.dll /test:MethodTest1 /unique This needs to pass Test Namespace name and Test Class name.

It works when i execute following but i have only access to Test Method not to class or namepsace mstest.exe /testcontainer:testproject.dll /test:TestNamespace.TestClass MethodTest1 /unique

I would appreciate if somebody could help me in exact command to run a single test case without using Class Name or Name pace in which TestMethod Lies.

Thanks


回答1:


For running multiple tests under a given class or namespace, you can use a wild card *. 

 

So, running:

mstest.exe /testcontainer:testproject.dll /test:TestNamespace.TestClass.*

 

will work




回答2:


A test case name only needs to be unique within the context of a test class, and a test class name only needs to be unique in the context of a test namespace. Therefore, when you want to run a single test (by name) you always have to also supply the names of the containing namespace and class. Otherwise, MSTest is not able to uniquely identify the test you want to have run.



来源:https://stackoverflow.com/questions/3825541/how-to-run-a-single-test-case-from-mstest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!