如何将 XUnit 配置为仅在 Visual Studio 2015 测试资源管理器中显示方法名称? [英] How can XUnit be configured to show just the method name in the Visual Studio 2015 Test Explorer?

查看:15
本文介绍了如何将 XUnit 配置为仅在 Visual Studio 2015 测试资源管理器中显示方法名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2015 中使用 xunit.runner.visualstudio 2.0.1 版时,测试名称显示为完全限定的.有没有办法让测试只显示方法名称?

When using xunit.runner.visualstudio version 2.0.1 in Visual Studio 2015, the names of the tests show up fully qualified. Is there a way for the tests to show only the method name?

考虑以下测试:-

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

在测试资源管理器中显示为:-

In the Test Explorer this shows as: -

MySolution.Tests.MyTestClass.ClassUnderTest_WhenDefaultConstructorUsed_SomePropertyIsNotNull

使用 MSTest/VSTest 这将显示为:-

Using MSTest/VSTest this will show up as: -

ClassUnderTest_WhenDefaultConstructorUsed_SomePropertyIsNotNull

推荐答案

App.config 文件中设置 xunit.methodDisplay.

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

取自 http://xunit.github.io/docs/configuring-with-xml.html

这篇关于如何将 XUnit 配置为仅在 Visual Studio 2015 测试资源管理器中显示方法名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆