CppUnit输出到TAP格式转换器

Ole*_*aev 24 perl junit parsing cppunit

我寻求一个perl模块将CppUnit输出转换为TAP格式.我想在之后使用prove命令来运行并检查测试.

mvp*_*mvp 2

最近我正在做一些从 junit xml 的转换(尽管不是 TAP 格式)。使用 XML::Twig 模块很容易做到。您的代码应该如下所示:

use XML::Twig;

my %hash;

my $twig = XML::Twig->new(
   twig_handlers => {
       testcase => sub { # this gets called per each testcase in XML
           my ($t, $e) = @_;
           my $testcase = $e->att("name");
           my $error = $e->field("error") || $e->field("failure");
           my $ok = defined $error ? "not ok" : "ok";
           # you may want to collect
           #   testcase name, result, error message, etc into hash
           $hash{$testcase}{result} = $ok;
           $hash{$testcase}{error}  = $error;
           # ...
       }
   }
);
$twig->parsefile("test.xml");
$twig->purge();

# Now XML processing is done, print hash out in TAP format:
print "1..", scalar(keys(%hash)), "\n";
foreach my $testcase (keys %hash) {
     # print out testcase result using info from hash
     # don't forget to add leading space for errors
     # ...
}
Run Code Online (Sandbox Code Playgroud)

这应该比较容易打磨到工作状态