Tim
Tim

Reputation: 1769

visual studio 2015 doesn't see my xunit tests

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 ?

Upvotes: 7

Views: 1076

Answers (4)

DanielV
DanielV

Reputation: 2670

You should try a stable, not beta version of xunit library.

Upvotes: 0

afonte
afonte

Reputation: 988

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

Upvotes: 2

Tim
Tim

Reputation: 1769

On another computer, this is working http://xunit.github.io/docs/getting-started-dnx.html

Maybe installation problem... Thanks to agua from mars anyway

Upvotes: -1

agua from mars
agua from mars

Reputation: 17424

Using aspnet runner beta4 works for me:
project.json

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

Upvotes: 0

Related Questions