我将按照this指南将PHP项目与Jenkins集成。
这是我的build.xml
file
运行ant -f build.xml
时,此the output来自{{3}}:
phpunit:
[exec] PHPUnit 3.6.10 by Sebastian Bergmann.
[exec] Usage: phpunit [switches] UnitTest [UnitTest.php]
[exec] phpunit [switches] <directory>
[exec] --log-junit <file> Log test execution in JUnit XML format to file.
[exec] --log-tap <file> Log test execution in TAP format to file.
[exec] --log-json <file> Log test execution in JSON format.
[exec] --coverage-clover <file> Generate code coverage report in Clover XML format.
[exec] --coverage-html <dir> Generate code coverage report in HTML format.
[exec] --coverage-php <file> Serialize PHP_CodeCoverage object to file.
[exec] --coverage-text=<file> Generate code coverage report in text format.
[exec] Default to writing to the standard output
[exec] ...
第132行的配置片段:
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
安装了phpunit / PHPUnit:
pear list -c phpunit
Installed packages, channel pear.phpunit.de:
============================================
Package Version State
File_Iterator 1.3.1 stable
PHPUnit 3.6.10 stable
PHPUnit_MockObject 1.1.1 stable
PHP_CodeBrowser 1.0.2 stable
PHP_CodeCoverage 1.1.2 stable
PHP_Invoker 1.1.0 stable
PHP_Timer 1.0.2 stable
PHP_TokenStream 1.1.3 stable
Text_Template 1.1.1 stable
phpcpd 1.3.5 stable
phploc 1.6.4 stable
回复@oers周五5月3日20:31:50 ICT 2012:
我已经将build.xml文件编辑成如下:
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml serving" />
</target>
但没有任何改变。
答案 0 :(得分:2)
我已经将build.xml文件编辑成如下:
您的build.xml在树结构中有错误。
--- build.xml
+++ build.xml.new
@@ -1,4 +1,5 @@
<target name="phpunit" description="Run unit tests with PHPUnit">
- <exec executable="phpunit" failonerror="true"/>
+ <exec executable="phpunit" failonerror="true">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml serving" />
+ </exec>
</target>
答案 1 :(得分:0)
从输出中可以看到(用法:... ),phpunit
需要一些参数才能正确执行。 <exec executable="phpunit" failonerror="true"/>
只会打印phpunit
的帮助并退出(例如直接从命令行调用phpunit
)。
在the official guide for phpunit中,你被告知要像这样运行phpunit:
<target name="phpunit">
<exec dir="${basedir}" executable="phpunit" failonerror="true">
<arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest" />
</exec>
</target>
答案 2 :(得分:0)
在我的情况下,我遇到了这个问题,因为我设置了一个错误BaseDir,基础目录应该设置为项目路径或phpunit.xml.dist的相同路径。
无论如何,您也可以在build.xml中指定phpunit配置文件路径,如下所示
<target name="phpunit">
<exec dir="${basedir}" executable="phpunit" failonerror="true">
<arg line="-c /your/path/to/phpunit.xml.dist" />
<arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest" />
</exec>
</target>