I seek a perl module to convert CppUnit output to TAP format. I want to use the prove command afterwards to run and check the tests.
Recently I was doing some converting from junit xml (not to TAP format though). It was very easy to do by using XML::Twig module. You code should look like this:
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 # ... }
This should be relatively easy to polish into working state
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With