解决方法
最近我做一些转换从junit xml(不是到TAP格式)。
这是很容易做到使用XML :: Twig模块。
你的代码应该看起来像这样:
这是很容易做到使用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 # ... }
这应该比较容易抛光成工作状态
原文地址:https://www.jb51.cc/Perl/173245.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。