Visual studio 2015 does not see my xunit tests

trying to add xunit tests to my ASP.NET 5 project, I added a class library and populated project.json as follows:

{ "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 does not recognize my unit tests in the 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?

+6
source share
3 answers

On another computer, this works http://xunit.imtqy.com/docs/getting-started-dnx.html

Perhaps the installation problem ... Thanks to the agua from Mars anyway

-1
source

I 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" }, 

Hope this helps you. I had to install 3 nuget packages: xunit, xunit.runner.visualstudio and xunit.runners

+2
source

Using aspnet runner beta4 works for me:
project.json

 { ... "dependencies": { "xunit.runner.aspnet": "2.0.0-beta4" }, "commands": { "test": "xunit.runner.aspnet" }, ... } 
0
source

Source: https://habr.com/ru/post/988148/


All Articles