Question

is there a way to use categories and ordered tests in MSTest together?

[TestMethod, TestCategory("UITest")]
public void TestMethod()
{
}

and add a new ordered test to my test project.

well .. calling this method from the command line like:

MSTest.exe /testcontainer:MyOrderedTest.orderedtest

it will execute the testmethod.

but when calling MSTest like the following:

MSTest.exe /testcontainer:MyOrderedTest.orderedtest /category:UITest

it can't find the testmethod..

strange behavior ..

is there a way to do this?

Was it helpful?

Solution

When you use the /testcontainer:[file name] option you tell MSTest to run the tests that are specified in this file. So, your unit test with the attribute [TestMethod, TestCategory("UITest")] will not run because it not contained inside the MyOrderedTest.orderedtest.

You could create a TestList to achieve this behavior which will contain all of your Tests that belong to the UITest category and also the OrderedTest and then run the following command:

MSTest.exe /testmetadata:$(ProjectDir)\TestProject.vsmdi /testlist:ListName
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top