我正在尝试使用MSTEST来运行visual studio测试,但是当我尝试使用/ category时:“&”测试不会运行,并且会说它无法识别该类别。
我希望一次运行多个类别而不使用不同的MSTEST调用,这样在一次MSTEST调用中我可以运行所有类别并发布一个输出结果文件。
我的类别是正确的,因为它成功运行了1个类别,我只是无法附加它们。
例如,
mstest /testcontainer:.(...).dll /testcontainer:.(...).dll /category:"Defect Tests&Functional Tests"
返回
Loading .\(...).testrunconfig
Loading .\(...).dll
Loading .\(...).dll
Starting execution...
No tests to execute.
但是,如果我只使用一个类别,请说:
\category:"Defect Tests"
它会完全正常。
答案 0 :(得分:5)
我没有意识到我应该使用|作为文字OR逻辑运算符,而不是其他东西。我正在使用&并且最终没有运行测试,因为我认为它会运行两个测试套件,但实际上,它只运行测试,它们上面都有类别标签......这些都不是。
例如(基于https://msdn.microsoft.com/en-us/library/ms182489.aspx#category):
/category:"group1|group2" runs tests that are in test category "group1" or "group2".
Tests that are in both categories will also be run.
/category:!group1&!group2 exclude tests with categories "group1" and "group2".
/category:group1 runs tests in the test category "group1".
/category:"group1&group2" runs tests that are in both test categories "group1" and "group2." Tests that are only in one of the specified test categories will not be run.
/category:"group1&!group2" runs tests from the test category "group1" that are not in the test category "group2." A test that is in both test category "group1" and "group2" will not be run.