我有很多* .t文件,每个文件都有测试编号 我正在通过Test :: Harness执行所有* .t文件。 我怎么能写单独的测试状态(通过/失败的DB)个人测试结果到数据库
例如
use Test::More ;
use strict;
ok($foo eq $bar, "TestCase1 ") ? &subUpdateResult(pass) : &subUpdateResult(Fail) ;
ok($1 eq $2, 'test case 2');
ok($3 eq $4, 'test case 3');
sub subUpdateResult
{
#now a only dummy code I will update this code to connect DB later
my $val=sfift;
print "val is $val\n";
}
done_testing();
,但我得到的结果一样
ok 1 - TestCase1
ok 2
val is sfift
ok 3 - test case 2
ok 4 - test case 3
1..4
查询:为什么我收到的打印测试用例2后的结果?以及如何获得单独的测试状态,这样我可以更新数据库或写入到Excel文件
'sfift'?顺便说一句,这甚至不会在'strict'下编译,因为你声称是这样的。 –
,你是对我有手工编写这些代码。如果我用shift然后还是我收到错误,如确定1个 VAL为1 OK 2 - 1 确定3 - 测试用例2 OK 4 - 测试用例3 1 .4 #你给你的测试命名为'1'。您不应该使用数字作为测试名称。 #很混乱。 – user3714347
sfift是5.20.0中新增的:-) –