Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 Unit Test Project vs xUnit Test Project

In .NET Core under Visual Studio 2015 one had to create a unit test project that was based on xunit, though the command line (no dedicated project was available in Visual Studio for .NET Core).

In Visual Studio 2017, under .NET Core section there are now 2 types of unit testing projects available:

  1. Unit Test Project (.NET Core)
  2. xUnit Test Project (.NET Core)

What is the difference between them? What is the recommended one these days?

like image 868
developer82 Avatar asked May 24 '17 18:05

developer82


People also ask

Should I use MSTest or xUnit?

As far as NUnit vs. XUnit vs. MSTest is concerned, the biggest difference between xUnit and the other two test frameworks (NUnit and MSTest) is that xUnit is much more extensible when compared to NUnit and MSTest. The [Fact] attribute is used instead of the [Test] attribute.

How do I create a unit test project in Visual Studio 2017?

On the Create a new project page, type unit test into the search box. Select the project template for the test framework that you want to use, for example MSTest Test Project or NUnit Test Project, and then select Next. On the Configure your new project page, enter a name for your project, and then select Create.

Why should I use xUnit?

xUnit is far more flexible and extensible than the other . Net Unit test frameworks. It allows you to create new attributes to control your tests. It ensures custom functionality with the possibility of extending the Asset class's Contains, DoesNotContain Equal, NotEqual, InRange, & NotInRange.


2 Answers

Unit Test Project has MSTest V2 framework installed.

xUnit Test Project has xUnit.

It's just two different test frameworks.

Unit Testing in .NET Core.

like image 88
Ilya Chumakov Avatar answered Sep 21 '22 22:09

Ilya Chumakov


They are completely 2 different Unit Test Frameworks. There is some basic information/documentation available for xUnit at http://xunit.github.io for xUnit but not a full one. The answer to: "What is the recommended one these days?" It depends on your personal preference. I prefer xUnit because xUnit integrates well with Visual Studio and is used by Microsoft team to test .net core. You can chose whichever you find suitable.

like image 28
Shuaib Avatar answered Sep 22 '22 22:09

Shuaib