php - PHPUnit with Clover code coverage reports: tests are not executed and commands exit

I "inherited" a very old PHP project compatible only with PHP 5.6 and written without any framework, and I'm trying to "modernize" it for PHP 7.x and adding some unit tests and some code inspection tools like SonarQube with Jenkins.
The project has some executable scripts which needs some arguments to be executed correctly and when I execute phpunit with the generation of the Clover coverage enabled it tries to execute them and they fail because required arguments are missing:
в‹Љ> ~/P/myproject on mybranch вЁЇ ./phpunit tests/
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.5 with Xdebug 2.9.5
Configuration: /Users/me/Projects/myproject/phpunit.xml
You must specify a source (--source)!
This is the output of thefiles-index.php
command from the root folder of the project which need a--source
parameter to run:
[...]
if (!$args['source']) {
exit("You must specify a source (--source)!\n");
}
[...]
What I don't understand is why if I execute PHPUnit without coverage report enabled the (few) tests present into the project are executed with no error (anyway the filefiles-index.php
has no tests at the moment):
в‹Љ> ~/P/myproject on mybranch вЁЇ ./phpunit --no-config tests/
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
........ 8 / 8 (100%)
Time: 194 ms, Memory: 4.00MB
OK (8 tests, 8 assertions)
This is myphpunit.xml
file:
в‹Љ> ~/P/myproject on mybranch вЁЇ cat phpunit.xml 22:10:25
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
backupGlobals="false"
verbose="true">
<testsuites>
<testsuite name="My Project">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">.</directory>
<exclude>
<directory suffix=".php">./vendor</directory>
<directory suffix=".php">./_classes</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="junit" target="./reports/logfile.xml"/>
<log type="coverage-clover" target="./reports/coverage.xml"/>
</logging>
<php>
<const name="PHPUNIT_TESTSUITE" value="true"/>
</php>
</phpunit>
Where I'm wrong?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.