简体   繁体   中英

How can I have multi-level categorized unit tests in visual studio 2013?

I have a project, which has a lot of unit tests.

It has several sub projects, and I'd rather use better categorization system.

I am using Visual Studio 2013 with NUnit Adpaper.

And I can categorize unit tests based on Project, Class or [Category] attribute which is placed on top of them:

    [TestFixture]
    [Category("MyCategory")]
    public class SomeTests
    {
        [TestCase(2, 2, ExpectedResult = 4)]
        public Int32 Test2(Int32 firstNumber, Int32 secondNumber)
        {
            return firstNumber + secondNumber;
        }
    }

So, how can I categorize them as following?

Category1
     SubCategory1
          UnitTest2
          UnitTest1
     SubCategory2
          UnitTest2
          UnitTest1
Category2
     SubCategory1
          UnitTest2
          UnitTest1

Is there any attribute as like as Category attribute that perform categorization much better? or any other config somewhere else?

Thanks

I had a similar problem and I think there is no nice solution for this. In the end I came up with "namespacing" my categories. For example:

Category1
Category1.SubCategory1
Category1.SubCategory1.UnitTest2
Category1.SubCategory1.UnitTest1
Category1.SubCategory2
Category1.SubCategory1.UnitTest2
Category1.SubCategory1.UnitTest1
Category2
Category2.SubCategory1
Category2.SubCategory1.UnitTest2
Category2.SubCategory1.UnitTest1

As NUnit v3 is currently in active development you could propose this as a feature request .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM