C#中:声明preprocesor符号(如调试)globaly为整个项目
问题描述:
我想是这样的NUnit和VS测试之间进行切换:
I would like to switch between NUnit and VS Tests like this:
#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
我的问题是,我怎么可能会宣布NUNIT preprocesor符号在一个地方(App.config中左右,将是巨大的),到NUnit的和VSTests轻松地之间进行切换?因为当我使用#定义NUNIT,它只能为文件,它被写入。
My question is, how may I declare NUNIT preprocesor symbol at one place (App.config or so, would be great), to switch between NUnit and VSTests easily? Because when I use "#define NUNIT", it works only for the file, where it is written.
答
使用项目属性对话框。您可以定义全局符号有:
Use the project properties dialog. You can define global symbols there:
右键单击项目 - >属性 - >生成选项卡 - >条件编译符号
Right click on the project -> Properties -> Build tab -> Conditional compilation symbols