您的位置:首页 > 其它

NUnit基本使用流程

2013-10-31 16:58 169 查看
1.新建.NET工程;

2.添加NUnit的引用:

              1)

                            


             2)

                           


 

3.为工程要测试的类或函数增加相应的UNnit标记;

 

namespace NUnitQuiteStart
{
[TestFixture]
public class NumbersFixture
{
[Test]
public void AddTwoNumbers()
{
int a = 1;
int b = 2;
int sum = a + b;
Assert.AreEqual(4, sum, "if there is 4,it is right");
}
}
}

注:在文件开头要增加using NUnit.Framework;

 

4. 设置NUnit为程序的开始:

              1)选择工程的属性

                 


               2)设置程序的开始执行程序

                


5.在.NET中点击运行,则会自动启动NUnit;

 

6.在Nunit中点击RUN,运行测试;

          注:NUnit中的测试结果,绿色代表通过,红色代表不通过。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: