是否可以将Devel :: Cover生成的覆盖率统计信息显示在Hudson的项目视图中,就像Cobertura插件一样?即使模糊的想法也受到赞赏! 最佳答案 经过大量研究,稀疏的文档混合了一些以上的试验和错误,这是我提出的一个提炼版本.
#!/usr/bin/perl -w
use strict;
use warnings;
{
use TAP::Harness::JUnit;
use English qw( -no_match_vars $EXECUTABLE_NAME );
}
my $harness = TAP::Harness::JUnit->new(
{ xmlfile => 'results.xml',
exec => [
$EXECUTABLE_NAME,
"-I/repo/trunk/PerlLib",
'-MDevel::Cover=-silent,1,-coverage,all',
'-w',
],
package => 'ARC::FB',
}
);
$harness->runtests(
[ "/repo/trunk/ARC/FB/Base/basic.t" => 'Base.basic.t' ],
[ "/repo/trunk/ARC/FB/Base/copy_file.t" => 'Base.copy_file.t' ],
[ "/repo/trunk/ARC/FB/Base/create_file.t" => 'Base.create_file.t' ],
[ "/repo/trunk/ARC/FB/Base/new.t" => 'Base.new.t' ],
[ "/repo/trunk/ARC/FB/Base/report.t" => 'Base.report.t' ],
[ "/repo/trunk/ARC/FB/Lurker/build_data_file.t" => 'Lurker.build_data_file.t' ],
[ "/repo/trunk/ARC/FB/Lurker/cleanup.t" => 'Lurker.cleanup.t' ],
[ "/repo/trunk/ARC/FB/Lurker/remove_file.t" => 'Lurker.remove_file.t' ],
[ "/repo/trunk/ARC/FB/Lurker/write_config.t" => 'Lurker.write_config.t' ],
[ "/repo/trunk/ARC/FB/Sign/add_tokens.t" => 'Sign.add_tokens.t' ],
[ "/repo/trunk/ARC/FB/Sign/interpret.t" => 'Sign.interpret.t' ],
[ "/repo/trunk/ARC/FB/Sign/new.t" => 'Sign.new.t' ],
);
__END__
将上述程序保存在/usr/local/bin/harness.pl中,然后配置Jenkins作业以在shell中执行:
cover -delete
/usr/bin/perl -w /usr/local/bin/harness.pl
cover -report clover
然后添加两个构建后的操作:
>发布三叶草覆盖率报告(带目录cover_db,文件名
clover.xml)
>发布JUnit测试结果报告(带XMLs results.xml)
保存它&运行.
关键概念:
> Jenkins不理解TAP(即Perl * .t的输出),但确实如此
了解JUnit XML.因此,TAP :: Harness :: JUnit模块将JUnit转换添加为生成TAP :: Harness包装器的TAP.
> Devel :: Cover及其选项需要作为TAP :: Harness exec参数的一部分内联给出.
>如果使用污点检查运行,Devel :: Cover会发出巨大的警告噪音.
JUnit转换的TAP数据在Jenkins中呈现得很好.但是,Clover报告缺少源覆盖视图.当您深入查看最终三叶草报告链接时,Jenkins提供了404页面.
这是在Jenkins ver 4.478上使用Clover插件版本4.0.6-h-1.