c# - 使用 c# 和 xUnit 在 Visual Studio 2012 的文本资源管理器中显示测试类名称

标签 c# visual-studio-2012 xunit test-explorer

我在 visual studio 2012 中将 xUnit 与内置的文本资源管理器一起使用。将测试名称与类名称一起使用会很好,所以如果我有的话

namespace Foo.Bar {
    class CatTests {
        [Fact]
        public void Test1(){
        }
    }
}

我会在测试资源管理器中看到

Foo.Bar.CatTests.Test1

作为测试的名称。这有可能吗?目前我只看到

Test1

如果我有很多 Test1 案例分布在多个命名空间和测试类中,这会很痛苦。

最佳答案

目前我们使用 FactAttribute 的 DisplayName:

[Fact(DisplayName = "Foo.Bar.CatTests.Test1")]

这似乎不能自动完成,但如果能自动完成就更好了。

关于c# - 使用 c# 和 xUnit 在 Visual Studio 2012 的文本资源管理器中显示测试类名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14120742/

相关文章:

c++ - 使用 && 和 & 的优化行为

c++ - boost::interprocess::managed_windows_shared_memory 在 VC11 上崩溃

c# - 针对 EF Core 和 SQL Server 数据库编写集成测试

c# - 在 IIS 中运行的 C# 网站中添加新的 .cs 文件

c# - 日期时间本地化。任何标准/最佳实践

c# - 生成集合的排列 - 高效且有区别

c++ - fatal error C1083 : Cannot open include file: 'opencv2/core.hpp' : No such file or directory

c# - Xunit.Net 由于 ID 重复而跳过测试

c# - 单元测试用例的最佳实践

c# - .NET 中的 System.Windows.Forms.PowerStatus 类有什么异常吗