Home c# What to choose: nunit vs xunit?

What to choose: nunit vs xunit?




What is the difference between nunit and XUNIT.NET ?

What is the meaning of developing two, and not one: I see that the XUNIT is developing by the author of NUNIT:

XUNIT.NET IS A UNIT Testing Tool for the .NET Framework. Written by
The Original Inventor of Nunit

On the other hand:

nunit – framework for writing unit tests for .NET languages ​​.. current production version (Version 2.6) is the seventh major version based on XUnit

In general where is the truth?

Free translation of the question NUNIT VS XUNIT? From the @ ruslan .

Answer 1, Authority 100%

You are confused by the fact that the name of a specific framework (XUNIT) coincides with the way the whole class of tools intended for writing the unit tests (JUNIT, NUNIT, etc.), where x in the title means that the name can be substituted there Specific language / environment.

Both of these frameworks are great, they both for example support parallel testing of tests (albeit in different ways).

nunit was founded in 2002, widespread well documented and has a big community, while xunit.net more modern, more oriented TDD and more flexible and more widely used in .NET CORE. (Comment from AK: Do not forget the post written in 2016, four years ago)

In addition to this, I note that the main difference that I noticed is how XUNIT.NET launches test methods. So in NUNIT we have a test class and a set of test methods in it. NUNIT creates an instance of a test class and launches all tests of this class on the same instance. While ** XUNIT.NET creates an instance of a test class for each test method. Therefore, in tests it will not be possible to use fields and properties to exchange data between methods (which in general, poor practice from the point of view of TDD and test methods should be independent from each other from the point of view of the TDD methodology). So using xunit.net you can be sure that your test methods are completely isolated.
If you want to have general data for test methods, then XUNIT allows you to do this. Therefore, by default, all methods are completely isolated, but you can use another approach if you specify explicitly. (In the comments of 2019 it is indicated that this description is also obsolete)

Also, see the XUnit and Nunit comparison: https://codopia.wordpress.com/2017/02/20/xUnit-PRAGMatic-Comparison/ (2017)

Free translation of the answer NUNIT VS XUNIT? from the @ akazemis .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions