Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run xUnit Unit Tests with VS2015 Preview?

Tags:

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?

like image 992
Omer Raviv Avatar asked Nov 19 '14 14:11

Omer Raviv


People also ask

How do I run xUnit test cases in Visual Studio 2019?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

What test runners can be used to test xUnit.net tests?

If you have Visual Studio Community (or a paid-for version of Visual Studio), you can run your xUnit.net tests within Visual Studio's built-in test runner (named Test Explorer).


2 Answers

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!

like image 129
Jeremiah Flaga Avatar answered Oct 15 '22 02:10

Jeremiah Flaga


You need to add reference to these 3 nuget packages:

"xunit": "2.1.0.0-beta1-build2945",
"xunit.runner.aspnet": "2.1.0.0-beta1-build60",
"xunit.runner.visualstudio": "2.1.0.0-beta1-build1051"

Check this article for more info: http://blog.developers.ba/unit-integration-testing-in-asp-net-5-and-visual-studio-2015-using-xunit-net/

like image 30
Radenko Zec Avatar answered Oct 15 '22 00:10

Radenko Zec