VS2008中使用NUnit

VS2008中使用NUnit

2010-08-04 13:14 by 轩脉刃, ... 阅读, ... 评论, 收藏, 编辑

1.下载NUnit:

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

2.创建测试的project

3.增加Reference(nuit.framework)

4,写测试类(诸如):

 

VS2008中使用NUnitVS2008中使用NUnit代码

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信息:

VS2008中使用NUnit

 

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