Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xUnit or NUnit? What advantages and disadvantages of each other? [duplicate]

What are the pluses and minuses of each framework, comparing to each other? How well they work with ASP.NET MVC? How well they support mocking?

like image 781
Dmitry Avatar asked Jul 17 '10 21:07

Dmitry


People also ask

Which one is better NUnit 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.

What is the difference between NUnit and xUnit project?

NUnit creates a new instance of the test class and then runs all of the test methods from the same instance. Whereas xUnit.net creates a new instance of the test class for each of the test methods.

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.

Why do we need NUnit?

NUnit Testing Framework Each module is tested independently to ensure that the objective is met. The NUnit Framework caters to a range of attributes that are used during unit tests. They are used to define Test -Fixtures, Test methods, ExpectedException, and Ignore methods.

Should I use NUnit or xUnit for unit testing?

When comparing NUnit vs xUnit.NET, the Slant community recommends xUnit.NET for most people. In the question “What are the best unit testing frameworks for .NET?” xUnit.NET is ranked 1st while NUnit is ranked 2nd. The most important reason people chose xUnit.NET is: What are the best unit testing frameworks for .NET?

What are the advantages of xUnit test?

It includes the excellent extensibility of test classes and test methods. xUnit test is the best Unit testing framework for .Net programming languages like C#, VB.Net, and F#. xUnit derives its structure and functionality from SUnit of Smalltalk.

Which attributes are not included in the xUnit framework?

Many attributes that were present in NUnit framework e.g. [TestFixture], [TestFixtureSetup], [TestFixtureTearDown] [ClassCleanup], [ClassInitialize], [TestCleanup], etc. are not included in the xUnit framework. Introduction of the [Theory] attribute for parameterized tests is one of the prime examples of the extensibility of the framework.

How can you tell the difference between two NUnit tests?

Though both Unit test code appears almost the same, you can find the difference by observing their result update: You can find that the second NUnit test has failed. This is because NUnit executes the entire tests in the same class using the same instance.


1 Answers

I work with NUnit only. It is pretty good for me. It is integrated into different add-ons for Visual Studio like Resharper, it supports in TeamCity and it has stand-alone test launcher

And looks like NUnit become an industry standard for unit testing.

And we haven't had any major issues with Moq or Rhino.Mock.

As I remember Asp.Net MVC (I worked with 1.0 only) uses MS Unit. You may easily switch from MSUnit to NUnit.

A similar question was asked already, maybe you find some details here: NUnit vs. MbUnit vs. MSTest vs. xUnit.net

like image 116
VMykyt Avatar answered Oct 20 '22 00:10

VMykyt