Easily migrate your MSTest2 project to XUnit.

.NET, CodeProject

Open your MSTest2 project using Visual Studio and follow the steps below for migration.

1. Install the XUnit NuGet package.

2. Remove the following MSTest2 packages below.

MSTest.TestAdapter

MSTest.TestFramework

3. Open Replace in Files windows by clicking on the Edit Menu and then Replace in Files option.

4. Change Look in from Entire solution to Current project to replace MSTest2 namespaces and attributes with XUnit.

5. Replace the following one by one.

  1. Microsoft.VisualStudio.TestTools.UnitTesting with Xunit
  2. [TestClass] with empty
  3. [TestMethod] with [Fact]
  4. Assert.Are with Assert.
  5. Assert.Is with Assert.

That’s it. You can build the project and run all the tests to verify the migration.

Leave a comment