Difference between NUnit and Xunit & which one is better...?

Difference between NUnit and XUnit & which one is better...? 

Features of nUnit - 

  • Is around from 2002 and its widely used by .Net community
  • Well documented
  • Isolation level during execution is per test class
  • NUnit runs all of the tests in the same Class using the same class instance. A new instance of the test class is created and then runs all of the tests method from the same class instance
  • There are TestFixture [Setup] and [Teardown] attributes.
  • Ability to include parameters in your tests
  • Less extensible
  • Less TDD Adherent. One can share fields or properties.


Features of xUnit - 

  • Modern and trending in .Net Community 
  • Sufficient documentation is available.
  • Isolation level during execution is per test method.
  • XUnit starts a new instance of the test class for very each of the test methods which improves test isolation. As test methods run in separate test class instances in isolation, it also increases the level of parallelism.
  • There are no [Setup] and [Teardown] attributes, this is done using the test class’ constructor and an IDisposable. This encourages developers to write cleaner tests.
  • xUnit is easier to read and uses intuitive terminology such as  Theory, Fact and other attributes
  • More extensible and flexible to use
  • More Tdd Adherent. One cannot use fields or properties to share data among test methods which is a bad practice, as our test methods would be dependent to each other which is not acceptable in TDD. Although,  willing to share some data among your test methods though, xUnit will let you do so.


To conclude with, both nUnit and xUnit are good but xUnit is better in many ways. So based on your requirement you can take the decision. 

#HappyLearning...! 

Comments

Popular posts from this blog

Border Radius not working in Outlook Email template

C# .Net Core Interview Questions for Freshers and Experienced Developers

15 ways to keep your team motivated while working remotely ?