简体   繁体   中英

Display the Test Class name in the Text Explorer in Visual Studio 2012 with c# and xUnit

I'm using xUnit with the built in Text Explorer in visual studio 2012. It would be nice to scope the name of the test with the name of the class so if I have for example

namespace Foo.Bar {
    class CatTests {
        [Fact]
        public void Test1(){
        }
    }
}

I would see in the test explorer

Foo.Bar.CatTests.Test1

as the name of the test. Is this possible in any way? At the moment I only see

Test1

which is a pain if I have lots of Test1 cases spread across multiple namespaces and test classes.

Currently we use FactAttribute's DisplayName:

[Fact(DisplayName = "Foo.Bar.CatTests.Test1")]

It does not appear that this can be done automatically, but it certainly would be nice if it did.

You can change how tests are shown in the Test Explorer by using a specific configuration file ( xunit.runner.json ) as described in this SO answer.

Additionally, you may need to change the grouping settings in the IDE in order to show the class name and not the full path.

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