开发者

How can I run Perl tests and merge the results with JUnit Reports in Ant?

I'd like to run Perl tests under Ant and produce XML output in a similar format to that produced by the Ant JUnit task.

开发者_StackOverflow中文版

I realize that the formatters TAP::Formatter::JUnit and TAP::Harness::JUnit exist, but since I have no experience in Perl I do not know where to start.


If you already have tests using Test::More or the like, then using prove --formatter TAP::Formatter::JUnit is the simplest way to go. You don't change any of your Perl tests or code, and you get the JUnit output that the Java-based tools use.

We use this setup with Hudson so we can track our tests and get good test failure reports as needed from Hudson's built-in tools without a lot of contortions. Our build is make-based, but that's the only real difference from your setup.

This means you should be able to run prove as an external task and get the benefits without having to change your Ant tooling significantly, if that wasn't clear.

Depending on which Perl you have installed, you may or may not have prove. Run

perl -MTest::Harness -e'print "$Test::Harness::VERSION\n"'

to see which version you've got - 3.00 or better will have prove; ideally, you should install 3.23 to get the best functionality:

sudo cpan Test::Harness TAP::Formatter::JUnit

This installs the most recent Test::Harness, TAP::Formatter::JUnit, and all needed prerequisites. Try out the external process with

prove --formatter TAP::Formatter::JUnit your/testsuite/directory/

You should get a JUnit XML file at the end of the prove run. If this all works, add it to Ant with

<target name="run">
<exec executable="prove">
  <arg value="--formatter" />
  <arg value="TAP::Formatter::JUnit" />
  <arg path="your/testsuite/directory/" />
</exec>

Ant documentation for "Exec"

(I believe this is the correct Ant syntax for running an external program, but I'm not an Ant expert.)


An alternative to TAP::Formatter::JUnit is TAP::Harness::JUnit. For example:

prove --harness TAP::Harness::JUnit t

I found TAP::Formatter::JUnit didn't install on Windows, whereas TAP::Harness::JUnit seems to work everywhere.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜