EPiWiki.se  - EPiServer notes shared with others
 

How to make test rum for both MsTest and NUnit

[Edit]
MSTest and NUnit test are able to run from the same source.

Both MSTest and NUnit



#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Category = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestContext = System.Object;
#endif

Remove the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework
Add a reference to nunit.framework

Add a build target Named NUnit and change the “Conditional compilations symbols” parameter under the build menu in the project properties.

Assemblyinitialize dosen't exists in NUnit so create a base class for all tests fixture and use the [SetUp] attribute on a method that calls a singleton that invokes the AssemblyInitialize function.
Version author:
Mattias Lövström

EPiServer version

All