[英]VS Test Explorer is not finding my Unit Tests (XUnit.Runner) ASP.NET 5
I am using ASP.NET 5 with XUnit and Visual Studio is not finding my Tests in the test explorer. 我正在使用带有XUnit的ASP.NET 5,而Visual Studio却没有在测试资源管理器中找到我的测试。
I have rebuilt my project several times to get them to refresh. 我已多次重建我的项目以让它们刷新。 My test explorer is empty.
我的测试资源管理器是空的。
Any ideas? 有任何想法吗?
Here is my project.json file: 这是我的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": { }
}
}
Here is an example of one my my tests: 以下是我的测试中的一个示例:
[Fact]
public void Traditional()
{
// Arrange
var sut = new Calculator();
// Act
sut.Subtract(1);
// Assert
Assert.True(sut.Value < 0);
}
You need to install the package XUnit.Runner.Console in your test project in order for the test runner to discover your tests. 您需要在测试项目中安装包XUnit.Runner.Console,以便测试运行器发现您的测试。
https://www.nuget.org/packages/xunit.runner.console https://www.nuget.org/packages/xunit.runner.console
With the following 3 XUnit specific properties in project.json
, I got Visual Studio's Test Explorer to discover my XUnit tests: 通过
project.json
的以下3个XUnit特定属性,我获得了Visual Studio的Test Explorer来发现我的XUnit测试:
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
...
"xunit": "2.1.0",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
...
},
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.