5

I know there is this question:

How can XUnit be configured to show just the method name in the Visual Studio 2015 Test Explorer?

I tried both the solution using XML and the JSON file but the name in Text Explorer Window is still the full name with the class. I want to display the method name only as its hard to read the fully qualified names.

Its stated on this site that you can configure using XML

Configuring xUnit.net with XML

but I can't make the effect I'm expecting happen. I've restarted VS 2017 after adding an app.config file in the test project, but still nothing. Is it different for VS 2017?

g_b
  • 11,728
  • 9
  • 43
  • 80

2 Answers2

14

I had the same issue. I'm doing a project in VS2017 using .NET Standard and solved it by following these steps:

  1. In your tests project, create a file named xunit.runner.json
  2. Add the following to the file: { "methodDisplay" : "method" }
  3. In the Solution Explorer, right-click on xunit.runner.json and select "Properties". Set Copy to Output Directory to "Copy Always".

Taken from this comment.

Wes Hampson
  • 156
  • 2
  • 4
8

W. Hampson answer is perfect, but just to inform about other possibility - use DisplayName attribute.

[Fact(DisplayName = "Just simple check")]
public void Check()
{
    Assert.NotNull(_operation);
}

enter image description here

Aleksej Vasinov
  • 2,662
  • 28
  • 29