Miguel Moura
Miguel Moura

Reputation: 39514

Not able to use XUnit for unit tests in ASP.NET VNext and Visual Studio 2015 RC

I created a a Visual Studio 2015 RC solution as follows:

Project
  global.json
Source
  MvcProject
  MvcProject.Test

MvcProject.Test is a class library where I created a Test.

The global.json file has the following:

{
  "projects": [ "Source" ],
  "sdk": {
    "version": "1.0.0-beta4"
  }
}    

And project.json in MvcProject.Test is:

{
  "compilationOptions": {
    "warningsAsErrors": true
  },
  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-*",
    "xunit.runner.aspnet": "2.0.0-aspnet-*"
  },
  "commands": {
    "test": "xunit.runner.aspnet"
  },
  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Moq": "4.2.1506.2016"
      }
    }
  }
}

I then created a simple test:

using Xunit;

namespace MvcProject.Test {
  public class FirstTests {

    [Fact]
    public void HelloTest() {
      Assert.Equal(2, 2);
    }

  }
}

When I build the solition I get the error:

The type or namespace name 'Fact' could not be found (are you missing a using directive or an assembly reference?)  MvcProject.Test.DNX 4.5.1   

The name 'Assert' does not exist in the current context Bityond.Test.DNX 4.5.1  

What am I missing in my configuration?

Upvotes: 2

Views: 1671

Answers (2)

Van Kichline
Van Kichline

Reputation: 1713

This blog post works with RTM. Please leave comments on the blog if you have any problems.

Upvotes: 2

Jake Rote
Jake Rote

Reputation: 2267

There is a guide for it here I followed it and works perfectly.

http://xunit.github.io/docs/getting-started-dnx.html

Upvotes: 1

Related Questions