trying to add xunit tests to my ASP.NET 5 project, i've added a class library and fill the project.json like this :
{
"version": "1.0.0-*",
"description": "",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"xunit": "2.1.0-beta2-build2981",
"xunit.runner.visualstudio": "2.1.0-beta2-build1055"
},
"commands": {
"test": "xunit.runner.visualstudio"
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816"
}
}
}
}
But Visual Studio doesn't recognize any of my unit tests in test explorer :
public class Class1
{
[Fact]
public void PassingTest()
{
Assert.Equal(4, Add(2, 2));
}
[Fact]
public void FailingTest()
{
Assert.Equal(5, Add(2, 2));
}
int Add(int x, int y)
{
return x + y;
}
}
What am I missing ?
It's an open source unit testing tool for . Net framework that's compatible with ReSharper, CodeRush, TestDriven.Net, and Xamarin. You can take advantage of xUnit.Net to assert an exception type easily.
To enable Live Unit Testing, select Test > Live Unit Testing > Start from the top-level Visual Studio menu.
I have had the same problem today. This solution works for me:
"dependencies": {
"xunit": "2.1.0-beta3-*",
"xunit.runner.dnx": "2.1.0-beta3-*",
"xunit.runner.visualstudio": "2.1.0",
"xunit.runners": "2.0.0"
},
"commands": {
"test": "xunit.runner.dnx"
},
I hope this help you. I had to install 3 nuget package: xunit, xunit.runner.visualstudio and xunit.runners
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With