VS2008中使用NUnit

简介:

1.下载NUnit:

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

2.创建测试的project

3.增加Reference(nuit.framework)

4,写测试类(诸如):

 

ExpandedBlockStart.gif
复制代码
 
  
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信息:

2010080413133829.png

 

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

目录
相关文章
|
JavaScript 测试技术 C#
【C#】【xUnit】【Moq】.NET单元测试Mock框架Moq初探!
在TDD开发模型中,经常是在编码的同时进行单元测试的编写,由于现代软件开发不可能是一个人完成的工作,所以在定义好接口的时候我们就可以进行自己功能的开发(接口不能经常变更),而我们调用他人的功能时只需要使用接口即可。
5130 0
|
测试技术 程序员 数据库连接
|
测试技术 C# 数据库连接
|
测试技术 程序员 C++