这假设您在 API 级别工作。如果我读错了,并且您在 GUI 级别工作,您更倾向于考虑 selenium 或 watir 之类的东西。
您是否考虑过编写自己的简单测试框架来输出 TAP 结果(测试任何协议) - 然后使用研磨或 TAP2HTML 对其进行解析?
说真的,TAP 输出如下所示:
1..7
ok 1 - 带有 null 值的 hello world 返回“hello world”字符串
ok 2 - hello world with bob 返回 'hello, bob'
ok 3 - hello world with 123 return 'hello, 123'
ok 4 - 带有 5K 字符串的 hello world 返回 hello 加字符串
好的 5 - 特殊字符
好的 6 - 国际化,法国
好的 7 - 国际化,ja
看起来你没有通过 0 次 7 次测试。
(如果它在第 5 步之后死了,1..7 会告诉你有问题)
输出是直接的 ASCII。你基本上会有两个全局变量,numTestsTotal 和 numTestExecuted,并编写如下函数:
sub ok (boolean bExpected, 字符串注释) {
如果(b预期){
打印“好”。 numTestsExecuted 。 “”。评论 。 "\n";
}别的 {
打印“不好”。测试总数。 “”。评论 。 "\n";
}
numTestsExecuted++;
}
sub eq(int iExpected,int iResult,字符串注释){
如果(iExpected==iResult){
打印“好”。 numTestsExecuted 。 “”。评论 。 "\n";
} 别的 {
打印“不好”。 numTestsExecuted 。 “”。评论 。 \n";
}
numTestsExecuted++;
}
您在库中编写常规代码,然后您的测试应用包含该库和测试模块。
你可以为每一种类型的值重载eq,写就是比较数组等
请参阅有关 TAP 的文档:
http://testanything.org/wiki/index.php/Main_Page
还有Test::More
是的,您可以争辩说 eq() 应该“只是”调用 ok()。或者您可以在输出中插入预期和实际结果。由你决定。
无论如何,有很多 TAP 解析器和解释器可用于更多命令式语言。