ant-f build.xml:exec返回:2和phpunit?

ant-f build.xml:exec返回:2和phpunit?,ant,jenkins,phpunit,Ant,Jenkins,Phpunit,我将把PHP项目与Jenkins follow guide集成 这是我的 这是从运行ant-f build.xml时开始的: phpunit: [exec] PHPUnit 3.6.10 by Sebastian Bergmann. [exec] Usage: phpunit [switches] UnitTest [UnitTest.php] [exec] phpunit [switches] <directory> [exec] --l

我将把PHP项目与Jenkins follow guide集成

这是我的

这是从运行ant-f build.xml时开始的:

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] ...

回复@oers-Thu-May 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>
 <target name="phpunit">
  <exec dir="${basedir}" executable="phpunit" failonerror="true">
   <arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest" />
  </exec>
 </target>


但是没有任何变化。

从输出(用法:…)中可以看出,
phpunit
需要一些参数才能正确执行
将只打印
phpunit
的帮助并退出(就像直接从命令行调用
phpunit

在这种情况下,您被告知要像这样运行phpunit:

 <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>
 <target name="phpunit">
  <exec dir="${basedir}" executable="phpunit" failonerror="true">
   <arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest" />
  </exec>
 </target>

我已将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>
 <target name="phpunit">
  <exec dir="${basedir}" executable="phpunit" failonerror="true">
   <arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest" />
  </exec>
 </target>
您的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>
——build.xml
+++build.xml.new
@@ -1,4 +1,5 @@
-  
+  
+  

在我的例子中,我遇到了这个问题,因为我设置了一个错误BaseDir,BaseDir应该设置为与项目路径或phpunit.xml.dist的路径相同

无论如何,您也可以在build.xml中指定phpunit config文件路径,如下所示

<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>


phpunit3.6.10使用了
--log junit
开关,我一直在尝试这个选项,但得到了相同的结果。请查看我更新的问题。@quanta如果您在收到用法消息之前,向phpunit提供了错误的参数,请确保服务目录正确。这可能只是您的设置的本地问题,很难远程分析。