Blake Rivell Blake Rivell - 1 month ago 15
C# Question

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.

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:

{
"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);
}

Answer

You need to install the package XUnit.Runner.Console in your test project in order for the test runner to discover your tests.

https://www.nuget.org/packages/xunit.runner.console

Comments