I'm using VS2010 to develop a project and will be adding some NUnit tests to an existing test harness which is full of MStests.How do i run only the NUnit tests from that harness in Mono? Is there way i can selectively switch between running MSTests and NUnit tests when i am running them on a PC versus Mac? Or making a separate test harness with just the NUnit tests and running them in mono is the only solution?? I have tried to find easier ways, but looks like not many have attempted this. Any pointers are appreciated!
Asked
Active
Viewed 907 times
2
-
What is the issue with using NUnit for all the tests? Time and effort to switch them over? – Andrew T Finnell Sep 22 '11 at 18:56
-
Yes, there are about 700 tests, and most of them owned by a partner team who wouldnt want to convert them to NUnit. So it will have to end up being a mix of both to support Win and Mac platforms. – RashMans Sep 22 '11 at 19:17
1 Answers
3
You can try a neat trick to 'cross-compile' your unit tests to one of the two frameworks depending on target platform. Put this a the beginning of a test file:
#if MSTEST
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Category = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute;
#else
using NUnit.Framework;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestContext = System.Object;
using TestProperty = NUnit.Framework.PropertyAttribute;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
#endif
(taken from http://completedevelopment.blogspot.com/2009/05/blog-post.html )

skolima
- 31,963
- 27
- 115
- 151
-
@skolima- thanks for the suggestion, is it possible to run these tests on Mono? what i am trying to find out is, how is a test harness like this having both NUnit + MStests, run on Mono? With the directive, will the MSTests automatically be ignored when i deploy the tests to Mono? – RashMans Sep 26 '11 at 19:10
-
-
thank you..do i have to have monodevelop to get NUnit on Mono? Is there a way i can independently get NUnit on Mono, and use my testframework.dll, run it via nunit console? – RashMans Sep 27 '11 at 16:38
-
I had asked the same question, and looks like this is the solution -> http://stackoverflow.com/questions/7562596/steps-to-run-nunit-tests-on-osx , i have decided to create a new test harness consisting of purely NUnit tests. It doesnt seem feasible to add the cross compile trick as it will need around 700 tests to be modified just for the sake of a few NUnit tests. – RashMans Sep 27 '11 at 23:52