开发者

How to use a common test harness for MStests & NUnit and run them in Mono?

开发者 https://www.devze.com 2023-04-07 09:34 出处:网络
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 wa

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开发者_StackOverflow not many have attempted this. Any pointers are appreciated!


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 )

0

精彩评论

暂无评论...
验证码 换一张
取 消