Declare a preprocessor character (e.g. DEBUG) globally for the entire project

I would like to switch between NUnit and VS Tests as follows:

#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#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.String;
  using DeploymentItem = NUnit.Framework.DescriptionAttribute;
#endif

My question is, how can I declare a NUNIT preprocessor symbol in one place (App.config or so, it will be great), is it easy to switch between NUnit and VSTests? Because when I use #define NUNIT, it only works for the file where it is written.

+5
source share
2 answers

Use the project properties dialog. You can define global characters there:

Right click on the project -> Properties -> Build tab -> conditional compilation symbols

+9
source

- / ( → → ). "" ( ) , .

, ( /) , (debug/release/etc). .

+7

All Articles