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.

shytikov
  • 9,155
  • 8
  • 56
  • 103
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217

2 Answers2

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.

GaTechThomas
  • 5,421
  • 5
  • 43
  • 69
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.

Yennefer
  • 5,704
  • 7
  • 31
  • 44