Visual Studio2005下配置及运行NUnit

  知道.net下有个NUnit,一直没有用它来写程序。今天测试了下试试,写点心得出来,一边写程序一边还得测试,浪费了很多时间精力。代码有了一定规模了,慢慢体会到单元测试的作用。用Nunit进行单元测试能及时发现新的Bug,保证原有的功能正常运行。而不必手工一个个的去试验,这是很宝贵的。在NUnit的安装目录的bin下面有两个config文件:nunit-gui.exe.config,nunit-console.exe.config,其中有一段startup的配置段,默认如下:
<!--
These statements specify the runtime versions supported
in the order that they will be used if more than one
is present. You can change the order of these if you like
or remove any that do not apply.

Since .NET 1.0 does not recognize the <supportedRuntime> elements,
a <requiredRuntime> element is used in case it is the only version
of the framework that is installed.
-->
<startup>
<supportedRuntime version="v1.1.4322" />
<supportedRuntime version="v2.0.40607" />
<supportedRuntime version="v1.0.3705" />
<requiredRuntime version="v1.0.3705" />
</startup>

很明显,NUnit就是通过这儿配置来支持不同的.Net版本的(VS2005 Beat1的版本是"v2.0.40607")。这篇blog的建议是将其他无关的配置项删掉,it sure works,但是如果机器上同时安装了多个版本,就需要来回修改这个config文件——显然太麻烦。我是个懒人,有没有更省事的方法呢?试了几次,终于找到了,其实方法很简单:只需要把最新的版本的一行配置项放到最上面就可以了:
<startup>
<!-- make it top here -->
<supportedRuntime version="v2.0.40607" />
<!-- leave others -->
<supportedRuntime version="v1.1.4322" />
<supportedRuntime version="v1.0.3705" />
<requiredRuntime version="v1.0.3705" />
</startup>

简单吧。测试了一下,机器上的另一个版本.net(v1.1.4322)也可以同时运行了,但是"v1.0.3705"没有测试,如果你是这一个版本,请告诉我你的测试结果 :)
注意的一点是根据你的工具不同(GUI或CONSOLE)配置不同的config文件.
ps:NUnit是.Net下的一个单元测试工具(如果你竟然还没有听说过,那可就太...),这儿是官方网站,以及下载页面,推荐下载最新的NUnit 2.4.3 (Recommended)2007-08-16版本。另外一些发现是以下的文章,原来vs2005中集成了unit test了,但是只在VSTS中发布,详情看这儿。
COOL stuff in VS2005 about test:
Testing in VS 2005

TDD and test generation in VS 2005 can be annoying and tricky if you don't watch out

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值