1.TestDriven测试工具下载路径:http://www.testdriven.net/
2.TestDriven测试工具安装的时候已经包括了,Nunit的测试工具,只要在其安装文件下边找到nunit文件夹,然后把nunit。exe的打开就可以用。
3.使用TestDriven,新建一个
1:新建一个Class Library PROJECT,
2:加入待测试DLL的引用,
3:加入NUnit.Framework.dll的引用
4:在文件开头加入:using NUnit.Framework
5:在待测试的类前加入:[TestFixture]
6:在待测试的方法前加入:[Test]
7:启动NUNIT-GUI,新建项目,将新建的Class Library PROJECT加入,执行。
例如
[TestFixture]//测试类的标识。
public class Class1
{
private int i;
private int j;
[SetUp]//测试的初始化
public void init()//注意一定要是公共的方法。
{
i = 0;
j = 1;
}
[Test]//测试的方法
public void add()//注意一定要是公共的方法。
{
int sum = i + j;
Assert.AreEqual(1, sum, "Eexp");
}
}
测试的两种方法
(1)右击鼠标菜单可以看到TestWith---Debugger 可以单步调试,在output 窗口中可以看到测试的结果。
(2)打开NUnit。exe,然后,将新建的Class Library PROJECT加入,执行。
4。TestDriven提供了一种测试silverlight的方法参见http://weblogs.asp.net/nunitaddin/archive/2008/05/01/silverlight-nunit-projects.aspx
有一个包http://www.testdriven.net/downloads/SilverlightNUnitProject.zip。通过了一个模板, 安装方法
To install the template simply open the 'SilverlightNUnitProject.vsi' file and ignore the unsigned content warning. Once installed, you will find it under the 'Visual C# / Silverlight' section of the 'New Project' dialog. 也就是silverlight NUnit Project
新建工程,然后把要测得项目引进来,对其进行测试,但是好像它可以测试简单的silverlight,但是很难实现异步调用的测试。
5。
浙公网安备 33010602011771号