I'm running integration tests on my WordPress plugin with PHPUnit, and when I generate a coverage, and clover.xml
file, the file name attribute in the clover.xml
will have absolute path to my file, e.g.
<file name="/Users/denis/vagrant-local/www/project/public_html/wp-content/plguins/my-plugin/file-that-is-tested.php">
Since I need to send this file to SonarQube, I need to modify this file every time I send it to SonarQube so that I only have relative path (starting from wp-config
folder)
<file name="wp-content/plguins/my-plugin/file-that-is-tested.php">
If I send the first version, SonarQube will report the code coverage as 0.0%, if I send the other one, it will show some coverage (it differs from the one PHPUnit creates, but that's not important).
Is there a way to specify this file name attribute in the PHPUnit config or do I need to run a bash script every time I run tests to delete this extra part?
EDIT
The phpunit.xml.dist
looks like this:
<?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
in the question. – Whitleywhitlock