天天看点

VS2008中使用NUnit

1.下载nunit:

<a href="http://www.nunit.org/index.php?p=home">http://www.nunit.org/index.php?p=home</a>

2.创建测试的project

3.增加reference(nuit.framework)

4,写测试类(诸如):

VS2008中使用NUnit
VS2008中使用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);

public void multipllytwonumbers()

int product = a * b;

assert.areequal(2, product);

VS2008中使用NUnit

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

VS2008中使用NUnit

6.debug的时候就可以运行nunit