(1)新建一个C#类库项目。
(2)添加对fit.dll的引用。
(3)添加被测试代码和测试代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingfit;
namespaceClassLibrary1
{
//被测试类
publicclassCUT
{
publicintAdd(inti,intj)
{
returni+j+1;
}
}
//测试类
publicclassClass1:ColumnFixture
{
publicinti;
publicintj;
//测试方法
publicinttestadd()
{
CUTc =newCUT();
returnc.Add(i, j);
}
}
}
(4)编译项目
编译项目,生成ClassLibrary1.dll文件。
(5)添加测试用例描述文档
用Word编辑一个表格,其中第一行输入ClassLibrary1.Class1,即测试类的命名空间及类名。然后加入两列i和j分别代表测试方法的两个参数。第三列输入testadd()即测试方法名称,在这列填入按照参数计算期待得到的值。
把Word文档另存为html格式的文件,例如“TestClassLibrary1.htm”。
(6)运行测试
在命令行启动FIT的runFile程序执行测试,命令如下:
D:\TestCode\fit-dotnet-1.1>runFile.exe D:\TestCode\ClassLibrary1\TestClassLibrary1.htm D:\TestCode\ClassLibrary1\result.html D:\TestCode\ClassLibrary1\ClassLibrary1\bin\Debug
三个参数分别代表测试用例文件,测试报告文件,以及测试DLL所在的路径。
正确运行后,生成result.html文件,红色表示Fail、绿色表示Pass。