Tomino
Tomino

Reputation: 6269

How to replace MSTest by NUnit (C#)

How to replace MSTest with NUnit (C#)?

Upvotes: 6

Views: 4178

Answers (1)

Tomino
Tomino

Reputation: 6269

  1. Add nuget package NUnit package into test project

    Install-Package NUnit
    
  2. Remove the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework

  3. Change the following namespace usings from

    using Microsoft.VisualStudio.TestTools.UnitTesting; 
    

    to

    using NUnit.Framework;
    
  4. Search and replace the following:

    [TestClass] => [TestFixture]
    [ClassInitialize] => [TestFixtureSetUp]
    [ClassCleanup] => [TestFixtureTearDown]
    [TestInitialize] => [SetUp]
    [TestCleanup] => [TearDown]
    [TestMethod] => [Test]
    Assert.Ignore => Assert.Inconclusive
    
  5. Unload project, open the .csproj file as Xml and remove line that looks like:

    <ProjectTypeGuids>{0b19334d-acce-4bf9-9475-088436fada27};{a9df11a7-84ef-49d2-b13a-9ed7e1f913e6}</ProjectTypeGuids>
    
  6. Remove (or replace) private or internal modifiers and make sure the Test project has visibility to internal members. You can refer this link for InternalsVisibleTo.

Upvotes: 9

Related Questions