Freigeben über


NUnit V2.1 in Visual Studio 2005 Beta 1

I recently installed Visual Studio 2005 Beta 1 and wanted to understand what I had to do to get NUnit running. NUnit installed without a problem. Cool, instinctively I did what I do every time I install NUnit, I run NUnit's tests. All 478 NUnit tests pass.

I then decided to build a class library that targets the new version of the framework. I included the reference to the nunit.framework.dll and then compiled. The program compiled but when I ran the tests in NUnit I got the following exception:

System.BadImageFormatException : The format of the file ‘TestLibrary’ is invalid.

I went to the config file (nunit-gui.exe.config) in “C:\Program Files\NUnit V2.1\bin” directory and looked for the <startup> section. I knew to do this because I was responsible for NUnit when V1.1 of the framework was in Beta and had run into similar issues. When I opened the file the <startup> section looked like this:

<startup>
<requiredRuntime version="v1.0.3705" />
<supportedRuntime version="v1.1.4322" />
<supportedRuntime version="v1.0.3705" />
</startup>

I added the following line for the new version of the framework thinking that would fix the problem:

<supportedRuntime version="v2.0.40607" />

I then reran NUnit. I still have the same error. After experimenting with different choices the only one that works is the following:

<startup>
<requiredRuntime version="v2.0.40607" />
</startup>

Once I changed the .config file to this the tests in my test library ran as well as NUnit’s tests. One thing to remember is that you also have to change the nunit-console.exe.config file in the same fashion.

Comments

  • Anonymous
    July 05, 2004
    That was the last little tip I needed to get started with .NET Framework v2.0 development.

    Thank you so much...

  • Anonymous
    July 06, 2004
    Great!
    Now we can carry on testing VS 2005. No way my team would do that without NUnit.

  • Anonymous
    July 06, 2004
    You should be able to put that requiredRuntime version="v2.0.40607" at the top of the list and leave the rest in there, rather than removing all of the other entries. That will allow you to run whether or not the Whidbey beta is installed.

  • Anonymous
    July 11, 2004
    Craig,

    Actually, I found that I did indeed have to remove the other elements in the startup list and leave only the required 2.0 for it to load my assembly properly. Otherwise, it would throw a BadImageFormatException. This is on a machine with both 1.1 and 2.0 installed.

  • Anonymous
    July 11, 2004
    I have to remove them all but the 2.0.40607 reference as well. I will continue to explore.

  • Anonymous
    July 15, 2004
    Thanks James now I don't have to reinstall the May Preview Version to do unit testing.

  • Anonymous
    June 25, 2006
    PingBack from http://www.philosophicalgeek.com/2005/08/31/getting-nunit-to-work-on-net-20-and-vs-studio-2005-beta-2/

  • Anonymous
    October 22, 2007
    Visual Studio2005下配置及运行NUnit~~不会没听说过NUnit吧?

  • Anonymous
    December 14, 2007
    知道.net下有个NUnit,一直没有用它来写程序。今天测试了下试试,写点心得出来,一边写程序一边还得测试,浪费了很多时间精力。代码有了一定规模了,慢慢体会到单元测试的作用。用Nunit进行单元测试能及时发现新的Bug,保证原有的功能正常运行。而不必手工一个个的去试验,这是很宝贵的。在NUnit的安装目录的bin下面有两个config文件:nunit-gui.exe.config,nunit-console.exe.config,其中有一段startup的配置段,默认如下:

  • Anonymous
    December 16, 2007
    知道.net下有个NUnit,一直没有用它来写程序。今天测试了下试试,写点心得出来,一边写程序一边还得测试,浪费了很多时间精力。代码有了一定规模了,慢慢体会到单元测试的作用。用Nunit进行单元测试能...