【发布时间】:2016-01-21 22:30:46
【问题描述】:
我在 XUnit 中使用 ASP.NET 5,而 Visual Studio 在测试资源管理器中找不到我的测试。
我已经多次重建我的项目以让它们刷新。我的测试资源管理器是空的。
有什么想法吗?
这是我的 project.json 文件:
{
"version": "1.0.0-*",
"description": "TestLibrary",
"authors": [ "brivell" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"AutoFixture": "3.38.1",
"AutoFixture.AutoMoq": "3.38.1",
"BusinessLibrary": "1.0.0-*",
"xunit": "2.1.0",
"xunit.runner.dnx": "2.1.0-rc1-build204"
},
"frameworks": {
"dnx451": { }
}
}
这是我的一个测试示例:
[Fact]
public void Traditional()
{
// Arrange
var sut = new Calculator();
// Act
sut.Subtract(1);
// Assert
Assert.True(sut.Value < 0);
}
【问题讨论】:
-
您需要在测试上方添加 [TestMethod] 属性。 msdn.microsoft.com/en-us/library/…
-
@DTmann 该属性仅在使用 Microsoft UnitTesting 库时有效。 Xunit 使用属性
[Fact]
标签: c# visual-studio unit-testing asp.net-core xunit