PHPUnit Cannot open file "XXXTest" Follow
Hello, I've been trying to set up a phpstorm with phpunit but I have trouble to make it work when I'm trying to run a test file or anything inside that test file.
Running test on a directory is fully working.
Here is the file
<?php
use PHPUnit\Framework\TestCase;
class InsertTest extends TestCase
{
public function testName() {
Application::getInstance(); //To check if autoloader is ok
$this->assertTrue(true);
}
}
Running tests (right click) on a directory generates this command (which works just fine):
C:\wamp64\bin\php\php7.3.15\php.exe C:\wamp64\www\gc_h5_copy\phpunit.phar --bootstrap C:\wamp64\www\gc_h5_copy\tests\boostrap.php --no-configuration C:\wamp64\www\gc_h5_copy\tests\php7.3\core --teamcity
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.
Time: 2.7 seconds, Memory: 20.00 MB
OK (1 test, 1 assertion)
Instead, running just the test file produces an error cannot find "InsertTest"
Testing started at 16:59 ...
C:\wamp64\bin\php\php7.3.15\php.exe C:\wamp64\www\gc_h5_copy\phpunit.phar --bootstrap C:\wamp64\www\gc_h5_copy\tests\boostrap.php --no-configuration InsertTest C:\wamp64\www\gc_h5_copy\tests\php7.3\core\InsertTest.php --teamcity
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.
Cannot open file "InsertTest".
Process finished with exit code 1
To me, it seems like "InsertTest" in the last command shoudln't be there but it might be an autoloader issue, I don't know. The autoloader I'm using in my test is working my class just fine in folder mode.
Please sign in to leave a comment.
PHPUnit 9 isn't supported in PhpStorm 2019.3.3. Please use PHPUnit 8.*, use EAP build or wait for a 2020.1 release (in a ~month).
Downgrading to phpunit 8.5.* resolved this issue for me.
Thanks for the information. I've also downgraded to phpunit 8, everything is working. Looking forward for the next release!
It is now October 2020. I do not know how to update my phpstorm from 2019 to 2020. should I be able to update my phpstorm on my windows machine so I do not have to downgrade phpunit?
PHPUnit 9 is fully supported now: https://youtrack.jetbrains.com/issue/WI-50201, so yes, you can safely update to 2020.2 or 2020.1.