How can I run xUnit Unit Tests with VS2015 Preview?

Omer Raviv picture Omer Raviv · Nov 19, 2014 · Viewed 9.8k times · Source

I added the "xUnit.net runner for Visual Studio" v0.99.8 via Extensions Manager, but when I open the Test Explorer window, it does not seem to pick up any of my unit tests. Also, the Resharper 9 EAP does which is the only version of Resharper that supports VS2015 does seem yet to have the plugin for xUnit Test Runner.

How then, can I run xUnit Unit Tests in VS2015 Preview?

Answer

Jboy Flaga picture Jboy Flaga · Nov 22, 2014

You can find the answer here: http://blogs.msdn.com/b/webdev/archive/2014/11/12/announcing-asp-net-features-in-visual-studio-2015-preview-and-vs2013-update-4.aspx

Visual Studio supports running and debugging for ASP.NET 5 xUnit tests through test explorer. All you need to do is add the xUnit dependencies and test commands to the test project's project.json file, as shown below (NOTE: To install the xUnit packages you will need to add https://www.myget.org/F/aspnetvnext/api/v2 as a NuGet package source):

"dependencies": {
    "Xunit.KRunner": "1.0.0-beta1"
},

"commands": {
    "test": "Xunit.KRunner"
},

If anyone is asking how to add https://www.myget.org/F/aspnetvnext/api/v2 as a NuGet package source... here are the steps:

  1. In Visual Studio 2015 Preview go to Tools -> Options -> NuGet Package Manager -> Package Sources
  2. Click the Plus (Add) button at the top (see image below)
  3. Enter the Name and Source like in the image below (NOTE: be sure to click the Update button after entering the Name and Source) enter image description here

Happy coding!