Unit / Integration testing in ASP.NET 5 and Visual Studio 2015 using XUnit.Net

Currently in Visual Studio 2015 CTP 6 MSTests are not supported to test ASP.NET vNext projects.

If you create MSTest project you are unable to add a reference to the ASP.NET vNext project.

Microsoft will enable support for MSTests for ASP.NET vNext in the next release of Visual Studio.

Until then you can only write unit and integration tests using XUnit.

First, you will need to create .NET core class library project where you will have all your tests:


Reference vNext project or any other .NET project (you can reference regular .NET projects from vNext Class Library) you want to test.

Create your test class and test method similar to this:

public class TestClass
 public void PassingTest()
     Assert.Equal(3, 2);


Add reference to these 3 NuGet packages:

"xunit": "",
"xunit.runner.aspnet": "",
"xunit.runner.visualstudio": ""


Make sure Test Explorer is visible ( Test > Windows > Test Explorer).

Every time you build your project, XUnit.Net will discover unit tests in your project.

Now you can run or debug your unit or integration tests.

If you like this article don’t forget to subscribe to this blog and make sure you don’t miss new upcoming blog posts.