I have been told that the automatically generated tests in VS2008 can be made compatible with NUnit just by adding
有人告诉我,VS2008中自动生成的测试可以通过添加与NUnit兼容
#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
EDIT: The question slightly changed focus since i fixed the reference issue. Again, I was told this statement would work to change to the correct unit test program, VS or NUnit.
编辑:问题略有改变焦点,因为我修复了参考问题。再一次,我被告知这个声明可以改为正确的单元测试程序VS或NUnit。
It never goes into the else statement. So the new question is, do i need to change the conditional to something else, or am I missing something simple again?
它永远不会进入else语句。所以新的问题是,我是否需要将条件更改为其他内容,或者我是否又错过了一些简单的内容?
3 个解决方案
#1
Have you referenced the NUnit assembly in place of the VS testing assembly?
您是否引用了NUnit程序集来代替VS测试程序集?
#2
Are you trying to convert your tests or run both NUnit and VS tests in the same project? If you're converting then you should be able to use find & replace to make most of the changes.
您是否尝试转换测试或在同一项目中运行NUnit和VS测试?如果您正在转换,那么您应该能够使用find和replace来进行大部分更改。
I went through a conversion from VS tests to NUnit and found one syntax difference: The argument order is different for the IsInstanceOfType method.
我经历了从VS测试到NUnit的转换,发现了一个语法差异:IsInstanceOfType方法的参数顺序不同。
#3
Well I found out what to do after I overlooked the simple mistake Richard pointed out to me.
好吧,在我忽略理查德向我指出的简单错误后,我发现该怎么办。
Since I am running these in CC.NET I just took the easy way out for the variable and set a windows variable in cmd and then ran the dll with nunit-console.exe.
因为我在CC.NET中运行它们,所以我只是简单地为变量做了一些操作,并在cmd中设置了一个windows变量,然后使用nunit-console.exe运行了dll。
If you don't really care about being able to swap back and forth between VS2008 and NUnit testings programs you can just take out the precompile code, leaving the contents of the if for VS and the contents of else for NUnit.
如果你真的不关心能够在VS2008和NUnit测试程序之间来回切换,你可以取出预编译代码,留下if for VS的内容和NUnit的else内容。
#1
Have you referenced the NUnit assembly in place of the VS testing assembly?
您是否引用了NUnit程序集来代替VS测试程序集?
#2
Are you trying to convert your tests or run both NUnit and VS tests in the same project? If you're converting then you should be able to use find & replace to make most of the changes.
您是否尝试转换测试或在同一项目中运行NUnit和VS测试?如果您正在转换,那么您应该能够使用find和replace来进行大部分更改。
I went through a conversion from VS tests to NUnit and found one syntax difference: The argument order is different for the IsInstanceOfType method.
我经历了从VS测试到NUnit的转换,发现了一个语法差异:IsInstanceOfType方法的参数顺序不同。
#3
Well I found out what to do after I overlooked the simple mistake Richard pointed out to me.
好吧,在我忽略理查德向我指出的简单错误后,我发现该怎么办。
Since I am running these in CC.NET I just took the easy way out for the variable and set a windows variable in cmd and then ran the dll with nunit-console.exe.
因为我在CC.NET中运行它们,所以我只是简单地为变量做了一些操作,并在cmd中设置了一个windows变量,然后使用nunit-console.exe运行了dll。
If you don't really care about being able to swap back and forth between VS2008 and NUnit testings programs you can just take out the precompile code, leaving the contents of the if for VS and the contents of else for NUnit.
如果你真的不关心能够在VS2008和NUnit测试程序之间来回切换,你可以取出预编译代码,留下if for VS的内容和NUnit的else内容。