VS2008中使用NUnit

1.下载NUnit:

http://www.nunit.org/index.php?p=home

2.创建测试的project

3.增加Reference(nuit.framework)

4,写测试类(诸如):

代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace TestNUnit
{
[TestFixture]
public class NumersFixture
{
private int a;
private int b;

[SetUp]
public void InitializeOperands()
{
a
= 1;
b
= 2;
}

[Test]
public void AddTwoNumbers()
{
int sum = a + b;
Assert.AreEqual(sum,
3);
}

[Test]
public void MultipllyTwoNumbers()
{
int product = a * b;
Assert.AreEqual(
2, product);
}
}
}

5.在project的properties中设置Debug信息:

6.Debug的时候就可以运行NUnit

实时了解作者更多技术文章,技术心得,请关注微信公众号“轩脉刃的刀光剑影”

本文基于署名-非商业性使用 3.0许可协议发布,欢迎转载,演绎,但是必须保留本文的署名叶剑峰(包含链接http://www.cnblogs.com/yjf512/),且不得用于商业目的。如您有任何疑问或者授权方面的协商,请与我联系

原文地址:https://www.cnblogs.com/yjf512/p/1791955.html