.NET unit test frameworks overview
In .NET we have 3 dominant unit test frameworks:
MS Test
NUnit
xUnit
First one comes with Visual Studio, two other requires additional components installation.
Unit Testing Frameworks Comparison
NUnit
xUnit.net
MSTest
Introduction
actually ported from a Java testing framework named “JUnit”. It’s a mature framework with a long history started from JUnit since 1998.
relatively new testing framework, written by original inventor of NUnit v2.
The evolution of Microsoft's Test Framework
Source Code
Supported Platforms
– .NET Framework 2.0+ – .NET Standard 1.6+ – .NET Core
– .NET 4.5.2 + – .NET Core 2.1+
– .NET 4.5.0+ – .NET Core 1.0+ (Universal Windows Apps 10+, DNX Core 5+) – ASP.NET Core 1.0+
.Net Core Support
YES
YES
YES
IDE Tools Support
Visual Studio, Visual Studio Code, Resharper
Visual Studio, Visual Studio Code, Resharper
Visual Studio, Visual Studio Code, Resharper
CI Tools Support
Parallel Execution
YES
YES
YES
Execution Isolation Level
Per test class
Per test method
Per test class
Extensible Test Attributes
NO (Test and TestCase attributes are sealed)
YES (Theory and Fact attributes are extensible)
No
Documentation
Highly documented
Not too much
Documented Well
Unit Testing Implementation Comparison
xUnit Test
MS Test
NUnit Test
Class
No
[TestClass]
[TestFixture]
Single Test Case
[Fact]
[TestMethod]
[Test]
Multi-Data
[Theory]
[InlineData]
[DataTestMethod]
[DataRow]
[TestCase]
Repeat Initialization for each Test
Ctor, IDisposable
[TestInitialize]
[TestCleanup]
[SetUp]
[TearDown]
One Time initialization for all tests in one class.
[MemberData]
Or
[ClassData]
Method Member (may Property Member)
[ClassInitialize]
[ClassCleanup]
[OneTimeSetUp]
[OneTimeTearDown]
One Time initialization for all tests in one assembly
[MemberData] Or [ClassData] Property Member
[TestClass] + [AssemblyInitialize] [AssemblyCleanup]
Dedicated class with [SetUpFixture] + [OneTimeSetUp] [OneTimeTearDown]
Last updated