使用ant运行phpunit测试时,我遇到了一个奇怪的错误。 测试是Symfony框架中的功能测试,如果在同一台机器上直接调用(使用相同的用户),它们运行良好。 当我尝试使用ant运行构建时,自动加载器无法加载Doctrine注释。我不确定其他自动加载是否有效,也许第一次遇到注释。 错误如下:
Doctrine \ Common \ Annotations \ AnnotationException:[语义错误] 注释" @Doctrine \ ORM \ Mapping \ Column"在财产 AppBundle \ Entity \ User :: $ id不存在,或者不存在 自动加载。
这是build.xml的相关部分(没什么好看的):
<target name="phpunit-xdebug" description="PHPUnit tests with coverage"> <exec executable="${workspace}/bin/phpunit" failonerror="true"> <arg value="-c" /> <arg path="${configdir}/phpunit.xml" /> <arg value="--log-junit" /> <arg path="${builddir}/logs/junit.xml" /> </exec> </target>
编辑。以下是phpuni.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.8/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
colors = "false"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "/var/lib/jenkins/jobs/project/workspace/var/bootstrap.php.cache"
>
<testsuites>
<testsuite name="project Test Suite">
<directory>/var/lib/jenkins/jobs/project/workspace/tests</directory>
</testsuite>
</testsuites>
<php>
<server name="KERNEL_DIR" value="/var/lib/jenkins/jobs/project/workspace/app" />
<ini name="xdebug.coverage_enable" value="1" />
</php>
<logging>
<log type="coverage-html" target="/var/lib/jenkins/jobs/project/workspace/build/coverage"/>
<log type="coverage-clover" target="/var/lib/jenkins/jobs/project/workspace/build/logs/clover.xml"/>
<log type="junit" target="/var/lib/jenkins/jobs/project/workspace/build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
<filter>
<whitelist>
<directory>/var/lib/jenkins/jobs/project/workspace/src/</directory>
<exclude>
<directory>/var/lib/jenkins/jobs/project/workspace/src/AppBundle/DataFixtures</directory>
</exclude>
</whitelist>
</filter>
<listeners>
<listener class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitStaticDbConnectionListener" file="/var/lib/jenkins/jobs/project/workspace/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitStaticDbConnectionListener.php" />
</listeners>
</phpunit>