[英]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 . 我想在Ant下运行Perl测试,并以类似于Ant JUnit任务生成的格式生成XML输出。
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. 我意识到格式化程序TAP :: Formatter :: JUnit和TAP :: Harness :: JUnit存在,但由于我没有Perl的经验,我不知道从哪里开始。
If you already have tests using Test::More
or the like, then using prove --formatter TAP::Formatter::JUnit
is the simplest way to go. 如果你已经使用
Test::More
之类的Test::More
,那么使用prove --formatter TAP::Formatter::JUnit
是最简单的方法。 You don't change any of your Perl tests or code, and you get the JUnit output that the Java-based tools use. 您不会更改任何Perl测试或代码,而是获得基于Java的工具使用的JUnit输出。
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. 我们在Hudson中使用这个设置,因此我们可以跟踪我们的测试,并根据需要从Hudson的内置工具中获得良好的测试失败报告,而不会产生很多扭曲。 Our build is
make
-based, but that's the only real difference from your setup. 我们的构建是基于
make
的,但这是与您的设置唯一的真正区别。
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. 这意味着您应该能够将
prove
作为外部任务运行并获得好处,而不必显着改变您的Ant工具,如果不清楚的话。
Depending on which Perl you have installed, you may or may not have prove
. 根据您安装的Perl,您可能已经或可能没有
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
; 看看你有哪个版本--3.00或更高版本将
prove
; ideally, you should install 3.23 to get the best functionality: 理想情况下,您应该安装3.23以获得最佳功能:
sudo cpan Test::Harness TAP::Formatter::JUnit
This installs the most recent Test::Harness, TAP::Formatter::JUnit, and all needed prerequisites. 这将安装最新的Test :: Harness,TAP :: Formatter :: JUnit以及所有必需的先决条件。 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. 您应该在
prove
运行结束时获得一个JUnit XML文件。 If this all works, add it to Ant with 如果这一切都有效,请将其添加到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" “Exec”的Ant文档
(I believe this is the correct Ant syntax for running an external program, but I'm not an Ant expert.) (我相信这是运行外部程序的正确Ant语法,但我不是Ant专家。)
An alternative to TAP::Formatter::JUnit
is TAP::Harness::JUnit
. TAP::Formatter::JUnit
的替代TAP::Formatter::JUnit
是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. 我发现
TAP::Formatter::JUnit
没有安装在Windows上,而TAP::Harness::JUnit
似乎无处不在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.