NUnit在VS2008下的使用

来源:互联网 发布:电商和微商的区别 知乎 编辑:程序博客网 时间:2024/05/01 07:53

1、从NUnit官网(http://www.nunit.org/index.php)下载最新版本NUnit,当前版本为NUnit2.5.2。

2、安装后,在VS2008中新建测试项目StartNUnit

3、右击项目选择属性,在打开的窗口中选择调试。如图:

4、选择启动外部程序,并定位到NUnit的启动程序nunit.exe。如图:

5、在项目中添加NUnit引用,如图:

6、在测试类中引用命名空间NUnit.Framework后就可以开始测试了。如下代码():
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace StartNUnit
{
    [TestFixture]
    
public class TheFirstTest
    {
        [Test]
        
public void TestMethod()
        {
             …………
        }
    }
}


技巧:

Debug.WriteLine("messages");

可以在NUnit下面显示出来