Writing Tests that work in NUnit and MSTest#

As someone who is trying to jump into the unit testing world, one of the major problems I had was deciding on using NUnit (which everyone uses) or use MSTest(built in).

I didn't want to jump into this and realize 500 hours later that I picked the wrong framework.  Well, now it seems I don't have to worry about that as much. 

First I was reading this article by Roy Osherove, and somehow I ended up on this page talking about converting between NUnit and VSTS projects, and from there I found a link to this page, which contained this great piece of code:

#If NUNIT Then
Imports NUnit.Framework
Imports TestClass = NUnit.Framework.TestFixtureAttribute
Imports TestMethod = NUnit.Framework.TestAttribute
Imports TestInitialize = NUnit.Framework.SetUpAttribute
Imports TestCleanup = NUnit.Framework.TearDownAttribute
#Else
Imports Microsoft.VisualStudio.TestTools.UnitTesting
#End If

This allows you do have the came code for NUnit and MSTest.  Just change the NUNIT variable and recompile.

The other thing you need to do is use <TestAttribute()> instead of <Test()> on your NUnit tests, but I don't see the difference there.

 

Categories:  |  | 
Wednesday, June 13, 2007 8:36:25 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Name
E-mail
(will show your gravatar icon)
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

All content © 2008, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: