I have following phpunit.xml file:
<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="mentor">
<directory>../module/Api</directory>
<directory>../module/Application</directory>
<exclude>../vendor</exclude>
<exclude>vendor</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../module</directory>
</whitelist>
</filter>
</phpunit>
file structure looks like this:
module
vendor
tests
-- phpunit.xml
-- Bootstrap.php
And now the tricky part. When I ran ../vendor/bin/php all works fine although if I ran global phpunit (/usr/local/bin/phpunit) it finishes with "no test executed" result. Any suggestions?
I found the reason why phpunit ommit all classes - that was due to TestCase I was trying to extend . All my tests relay on \\PHPUnit_Framework_TestCase from Phpunit 5.7 package (in vendors). Phpunit 6.1.4 use namespaces instead therefore I should extend PHPUnit\\Framework\\TestCase . By changing the extended class in tests all works fine.
I think you need to use psr-4 inside composer like this:
"autoload": {
"psr-4": {
"": "module/"
}
}
After you need to change your phpunit.xml with this:
<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="mentor">
<directory>module/Api</directory>
<directory>module/Application</directory>
<exclude>../vendor</exclude>
<exclude>vendor</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">module</directory>
</whitelist>
</filter>
</phpunit>
I think you need to change your phpunit point to folder tests and not module! like this:
<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="mentor">
<directory>tests/</directory>
<exclude>../vendor</exclude>
<exclude>vendor</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">tests</directory>
</whitelist>
</filter>
</phpunit>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.