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

2

8

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.

Hemato answered 2/1, 2013 at 10:50 Comment(1)
Do you know if this is possible in VS 2017?Woolsack
C
3

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.

Coactive answered 20/5, 2015 at 14:44 Comment(0)
W
1

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.

Windowsill answered 23/1, 2020 at 12:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.