我正在使用 PHPUnit 在我的 WordPress 插件上运行集成测试,当我生成覆盖率和 `clover.xml` 文件时,`clover.xml` 文件的文件名属性将具有我的文件的绝对路径,例如:
如果我发送第一个版本,SonarQube将报告代码覆盖率为0.0%,如果我发送另一个版本,它将显示一些覆盖率(与PHPUnit创建的覆盖率不同,但这不重要)。
是否有一种方法可以在PHPUnit配置中指定此文件名属性,还是每次运行测试时都需要运行bash脚本以删除此额外部分?
编辑 phpunit.xml.dist如下所示:
<file name="/Users/denis/vagrant-local/www/project/public_html/wp-content/plguins/my-plugin/file-that-is-tested.php">
由于我需要将此文件发送到SonarQube,因此每次将其发送到SonarQube时,我都需要修改此文件,以便只有相对路径(从wp-config
文件夹开始)。
<file name="wp-content/plguins/my-plugin/file-that-is-tested.php">
如果我发送第一个版本,SonarQube将报告代码覆盖率为0.0%,如果我发送另一个版本,它将显示一些覆盖率(与PHPUnit创建的覆盖率不同,但这不重要)。
是否有一种方法可以在PHPUnit配置中指定此文件名属性,还是每次运行测试时都需要运行bash脚本以删除此额外部分?
编辑 phpunit.xml.dist如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutCoversAnnotation="true"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true"
>
<testsuites>
<testsuite name="integration">
<directory prefix="test-" suffix=".php">./tests/integration/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./node_modules</directory>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory suffix=".php">./src/old</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="tests/_reports/coverage" lowUpperBound="35" highLowerBound="80" />
<log type="coverage-clover" target="tests/_reports/clover.xml"/>
<log type="coverage-php" target="tests/_reports/logs/coverage.cov"/>
<log type="junit" target="tests/_reports/logs/logfile.xml"/>
</logging>
</phpunit>
phpunit.xml.dist
。 - dingo_d