Jak skonfigurować XUnit tak, aby wyświetlał tylko nazwę metody w Visual Studio 2015 Test Explorer?

Przy użyciu xunit.runner.visualstudio w wersji 2.0.1 w Visual Studio 2015 nazwy testów są w pełni kwalifikowane. Czy istnieje sposób, aby testy pokazywały tylko nazwę metody?

Rozważmy następujący test:-

namespace MySolution.Tests
{
    public class MyTestClass
    {
        [Fact]
        public void ClassUnderTest_WhenDefaultConstructorUsed_SomePropertyIsNotNull()
        {
            *... test code in here*
        }
    }
}

W Eksploratorze testowym to pokazuje jako:-

MySolution.Tests.MyTestClass.ClassUnderTest_WhenDefaultConstructorUsed_SomePropertyIsNotNull

Używając MSTest / VSTest wyświetli się jako: -

ClassUnderTest_WhenDefaultConstructorUsed_SomePropertyIsNotNull
Author: cleftheris, 2015-09-02

2 answers

Ustaw xunit.methodDisplay w pliku App.config.

<configuration>
  <appSettings>
    <add key="xunit.methodDisplay" value="method"/>
  </appSettings>
</configuration>

Wzięte z http://xunit.github.io/docs/configuring-with-xml.html

 56
Author: Brad Wilson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-04-01 17:10:39

Możesz również dodać go za pomocą json.

W katalogu głównym Twojego projektu testowego Dodaj plik o nazwie " xunit.uciekinier.json".

Kliknij prawym przyciskiem myszy plik, właściwości. Wybierz "Kopiuj, jeśli nowszy", aby skopiować do katalogu wyjściowego.

Następnie w pliku wpisz ten json:

{
  "methodDisplay": "method"
}
 52
Author: lorengphd,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-09 17:33:23