Unit testing framework comparison in C#.net

Below table shows the main differences between 3 unit testing frameworks for dot net languages. All frameworks provide support for the basic unit testing features. So based on the requirement of the specific project, you can choose any framework
ConceptMSTestNUnitxUnit
Test method [TestMethod] [Test] [Fact]
Test class [TestClass] [TestFixture] -
Before and After Class [ClassInitialize] and [ClassCleanup] [OneTimeSetUp] and [OneTimeTearDown] Implement IClassFixture
Before and After test method [TestInitialize] and [TestCleanup] [Setup] and [TearDown] Use constructor and IDisposable.Dispose
Ignore test [Ignore] [Ignore("my reason")] [Fact(Skip="my reason")]
Namespace Microsoft.VisualStudio
.TestTools.UnitTesting
First we need to add reference using nuget and then we can use namespace - NUnit.Framework First we need to add reference using nuget and then we can use namespace - Xunit
Parameterization no using [TestCase] attribute using [Theory] attribute
Categories [TestCategory("sanity")] [Category("regression")] [Trait("Category","UI")]
Test runners dotnet test
Mstest.exe is now deprecated so you may use VSTest.Console.exe dotnet test command will actually launch the test runner console application specified for a project e.g. VSTest.Console.exe for MSTest projectdotnet vstest /Users/mstest.dll /logger:trxdotnet test and dotnet vstest take different arguments.
dotnet test
nunit-console runner can be used to execute the nunit tests
We can also use dotnet test for running xunit tests. Or you can use xunit runner
xunit.console.exe xyz.dll -trait "Category=sanity"
xunit.console.exe xyz.dll -notrait "Category=sanity" -notrait "Category="smoke"

Web development and Automation testing

solutions delivered!!