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