Reputation: 6269
How to replace MSTest with NUnit (C#)?
Upvotes: 6
Views: 4178
Reputation: 6269
Add nuget package NUnit package into test project
Install-Package NUnit
Remove the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework
Change the following namespace usings from
using Microsoft.VisualStudio.TestTools.UnitTesting;
to
using NUnit.Framework;
Search and replace the following:
[TestClass] => [TestFixture]
[ClassInitialize] => [TestFixtureSetUp]
[ClassCleanup] => [TestFixtureTearDown]
[TestInitialize] => [SetUp]
[TestCleanup] => [TearDown]
[TestMethod] => [Test]
Assert.Ignore => Assert.Inconclusive
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>
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