我一直在使用MsTest.exe来使用如下所示的名称空间运行测试:
mstest.exe /testcontainer:"MyDllFile.dll“/test:"NameSpace.Folder.Folder1.*”
这很有魅力,但我需要能够在运行时将参数传递给我的测试,因此我发现了*.runsetttings文件及其将参数传递给使用RunTestParameters的测试并从TestContext中的属性获取参数的能力,但缺点是我必须非常具体地说明我想运行哪个测试,并且必须给它一个特定的方法名或名称,用逗号分隔,以执行如下所示的测试:
vstest.console.exe "MyDllFile.dll“/Settings:"my.runsettings”/Tests:"TestMethod1,TestMethod2“
我也没有运气地尝试过TestCaseFilter:
vstest.console.exe "vstest.console.exe“MyDllFile.dll /Settings:"my.runsettings”/TestCaseFilter:"TestCategory=MyTestCategory“
有没有人建议我如何用mstest.exe和vstest.console.exe完成我能做的事情?
谢谢!!
发布于 2016-03-07 14:19:08
vstest.console.exe的文档尤其糟糕。这是可能的,但是命令行帮助和MSDN文档都没有解释如何做到这一点。
TestCaseFilter设置可用的选项似乎是特定于适配器的,但是对于默认的MsTest适配器,可以使用以下属性进行筛选。
Name=<TestMethodDisplayNameName>
FullyQualifiedName=<FullyQualifiedTestMethodName>
Priority=<PriorityAttributeValue>
TestCategory=<TestCategoryAttributeValue>
ClassName=<ClassName> (Valid only for unit tests for Windows store apps, currently not available for classic MSTest)..using的折叠操作符。
= (equals)
!= (not equals)
~ (contains or substring only for string values)
& (and)
| (or)
( ) (paranthesis for grouping)因此,就您的目的而言,以下形式的TestCaseFilter就足够了。
/TestCaseFilter:"FullyQualifiedName~ProjectNamespace.Subnamespace.TestClass"这里有更多的信息和例子,http://blogs.msdn.com/b/vikramagrawal/archive/2012/07/23/running-selective-unit-tests-in-vs-2012-rc-using-testcasefilter.aspx
https://stackoverflow.com/questions/34644596
复制相似问题