我正在尝试在我的PHP应用程序(Symfony2)中使用Jenkins和Ant,但无法执行我的测试。我可以在Jenkins的“控制台输出”屏幕中看到正在读取正确的配置文件,但它显示没有执行任何测试。
当我从项目的根目录中运行cli中的Ant build.xml文件时,构建成功并且我的测试执行并通过。
如果我进入/Users/Shared/Jenkins/{...}/workspace目录并运行'sudo ant',它表示没有执行任何测试!这是令人困惑的,因为完全相同的build.xml文件在从我的项目根目录运行时执行测试。
我的buil.xml文件的相关部分是:
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true">
<arg value="-c" />
<arg path="${workspace}/app/phpunit.xml.dist" />
</exec>
</target>
app / phpunit.xml看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "bootstrap.php.cache" >
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../src</directory>
<exclude>
<directory>../src/*/*Bundle/Resources</directory>
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Resources</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" title="GMS" charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
我安装了Jenkins Clover,Jenkins Clover PHP和xUnit插件。
Jenkins控制台输出的相关部分是:
phpunit:
[exec] PHPUnit 3.7.24 by Sebastian Bergmann.
[exec]
[exec] Configuration read from /Users/Shared/Jenkins/Home/jobs/GMS/workspace/app/phpunit.xml.dist
[exec]
[exec]
[exec]
[exec] Time: 181 ms, Memory: 2.50Mb
[exec]
[exec] [30;43m[2KNo tests executed!
[exec] [0m[2K
[exec] Generating code coverage report in Clover XML format ... done
[exec]
[exec] Generating code coverage report in HTML format ... done
答案 0 :(得分:9)
如果您提交测试,这会有所帮助。你这个傻瓜。