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.


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

  1. Daniel Zolnjan
    August 2, 2015 at 9:35 am (9 years ago)

    Have you managed to get test explorer working (showing tests) with beta6 and vs2015RTM?

    • Radenko Zec
      August 6, 2015 at 12:39 pm (9 years ago)

      I am currently in process of migration project to beta6 and still have some issues with that.
      After that I will try to enable unit tests support.
      If you manage to figure out how to do this before me please try to publish some blog post about that and drop the link here.
      Thanks Daniel.


Leave a Reply