views:

135

answers:

2

We are working on a C# windows application that is being upgraded from .Net 1.1 to 3.5. The application uses NUnit for automated testing and we are in turn changing this to Team System 2008.

  • It seems to me that NUnit uses similar attributes and code for assertion?
  • What is the best way to upgrade / migrate this code and are their any procedures to avoid?
+2  A: 

Here's how attributes map from NUnit to MSTest

[TestFixture] -> [TestClass]
[Test] -> [TestMethod]
[SetUp] -> [TestInitialize]
[TearDown] -> [TestCleanup]
[TestFixtureSetUp] -> [ClassInitialize]
[TestFixtureTearDown] -> [ClassCleanup]

You can consider adding something like

using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
using TestAttribute = NUnit.Framework.TestMethodAttribute;

to the top of your test classes.

Anton Gogolev
Here are moreattributes: http://geekswithblogs.net/sdorman/archive/2009/01/31/migrating-from-nunit-to-mstest.aspx
Mikelangelo
+2  A: 

Mainly, converting between test frameworks is a "[Ctrl]+H" (replace all) job. However...

I think the word "upgrade" may be confusing. I've used both, and in many ways NUnit has a lead on MSTest. The biggest advantage of MSTest is (IMO) with the team-coverage integration in the IDE - but you can get this with your existing NUnit tests via TestDriven.NET (Test With -> Team Coverage).

Things to watch out for with MSTest:

  • it needs a solution file to hold the testrunconfig etc
  • you need to add extra attributes (or entries in the testrunconfig) to deploy files to the test folder (it doesn't just use the output "bin" folder)
  • instrumentation needs a special config
Marc Gravell
Should i do this manually? What is the easiest way to add things things? Perhaps using: "Create unit test" and thus putting in the old code and replacting methods that automatically were created?
Mikelangelo
Well, "Create Unit Test" will setup the project etc, certainly - just merge in your tests, etc.
Marc Gravell