Reputation: 7341
I have the attribute [TestCategory("Unit")]
assigned to a bunch of my tests, and when I select to group by trait in the Test Explorer, it shows me two Unit
groups as shown here
I have a my test with the Unit
attribute defined in a three different projects, and within several different namespaces, so at first I thought that might be the problem. However, the first Unit
group contains tests from two different projects so it doesn't appear that tests within different projects always get grouped separately.
What is causing this behavior? Shouldn't all tests that are defined with [TestCategory("Unit")]
be under the same grouping in the Test Explorer?
Upvotes: 1
Views: 605
Reputation: 7341
I found a solution.
I have three test projects in my solution that all include test methods with the [TestCategory("Unit")]
attribute. Two of the projects were referencing Microsoft.VisualStudio.QualityTools.UnitTestFramework
(those projects were created in Visual Studio 2015) and one of the projects was referencing Microsoft.VisualStudio.TestPlatform.TestFramework
and Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions
(that project was created in Visual Studio 2017). I changed my tests so that all three test projects reference the Microsoft.VisualStudio.TestPlatform...
libraries, and now my tests are categorized correctly.
Visual Studio must have been categorizing the tests differently because the TestCategory
attribute was defined in different libraries for each project.
Upvotes: 2