MSTest Project with Nunit Tests - Recognition
As a result of an issue with how Nunit and breakpoint debugging works with VS2010, I modified all the classes in my Nunit project to include allow side by side Nunit/MSTest code. I can then use my Nunit code in MSTest by just changing a build flag. It allows me to compile and use the MS test integrated GUI features and have Nunit tests (good from the CI server) all in the same project. I thought this was the best of both TDD worlds (although some of my Nunit tests need to be dumbed down to suit the MSTest implementation).
The one downside to this change is the VS project file changes. To allow MSTests to run you have to modify your Nunit project to include the MSTest Project Type Guids.
<ProjectTypeGui
Now it would be really cool if the Nuit GUI and Consoles applications would also check these project types and run nunit tests if they existed in those projects, so my CI server doesn't need to rip this <ProjectTypeGuids> entry out of my project build the file and then restore the Nunit project file to get Nunit tests running. Could Nunit be upgraded to include these MSTest projects?
I notice there is an addin to VS2010 which does this for you at, but it will not help me with my CI server.
http://
VB Code required for Nunit/MSTest integrated tests (just add a Compile Constant to the project like NUNIT=TRUE)
#Region "Nunit and MSTest Duel Use"
#If NUNIT Then
Imports NUnit.Framework
' Convert the MS Test Attributes to Nunit versions
Imports TestClass = NUnit.Framework
Imports TestMethod = NUnit.Framework
Imports TestCleanup = NUnit.Framework
Imports TestInitialize = NUnit.Framework
Imports ClassCleanup = NUnit.Framework
Imports ClassInitialize = NUnit.Framework
#Else
Imports Microsoft.
' Convert the Nunit attributes to the MS Test versions
Imports TestFixture = Microsoft.
Imports Test = Microsoft.
Imports Category = Microsoft.
Imports Setup = Microsoft.
Imports TestFixtureSetUp = Microsoft.
Imports TestFixtureTearDown = Microsoft.
#End If
Imports NUnitAssert = NUnit.Framework
Imports MsAssert = Microsoft.
#End Region
#Region "Fixture Setup"
#If Not Nunit Then
Private _testContextIns
'''<summary>
'''Gets or sets the test context which provides
'''information about and functionality for the current test run.
'''</summary>
Public Property TestContext() As TestContext
Get
Return _testContextIns
End Get
Set(ByVal value As TestContext)
End Set
End Property
#End If
Public Sub New()
End Sub
<Setup()> Public Sub Init()
End Sub
#If NUNIT Then
<TestFixtur
#Else
<ClassIniti
#End If
End Sub
<TestFixtur
End Sub
#End Region
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- NUnit V2 Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Jamie Clayton for more information if necessary.