Is it possible to run all tests that do not belong to a category from the command line? From the documentation, I know that I can run all tests that are a member of a category doing something like:
vstest.console.exe myTestProject.dll /TestCaseFilter:TestCategory="Nightly"
What I want to do is assign a few test methods to a test category and then run those tests in one run. I then want to run the remainder of the tests in a separate test run (which is where my current problem lies). I have over 1000 tests, so I am hoping that I don't have to do a search and replace on all the TestMethod attributes to add a 'basic' category. I also don't want to have to separate the tests out into different projects.
Thanks.
If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.
There is a difference between vstest and mstest - the former is a test runner and the later is a test framework.
Use the command MSTest from the command prompt. The MSTest command expects the name of the test as parameter to run the test. Just type MSTest /help or MSTest /? at the Visual Studio command prompt to get help and find out more about options.
Well, I got the tumbleweed badge for this question, so I guess nobody is interested. In case someone does stumble onto the same problem, I found that I could just use the != operator. The Microsoft documentation is very lean, but I found the info I needed in MSDN blog "Running selective unit tests in VS 2012 RC using TestCaseFilter".
So, the answer is:
vstest.console.exe myTestProject.dll /TestCaseFilter:TestCategory!="Nightly"
Update: As pointed out by Rob Bos below. The docs now have:
dotnet test --filter FullyQualifiedName!=MSTestNamespace.UnitTestClass1.TestMethod1
Runs all tests except MSTestNamespace.UnitTestClass1.TestMethod1
Source Running selective unit tests on MSDN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With