Test file not found, when not run in root
See original GitHub issueI have a test project, that includes a package I’m working on in packages/my-library.
The Pest tests I want to execute are in that package. So there is a phpunit.xml in packages/my-library and the tests itself are located in packages/my-library/tests.
I installed the dependencies inside the packges/my-library folder (including pest) and configured the plugin in PhpStorm to point the Pest executable to the packages/my-library/vendor/bin/pest and the Default configuration file to packages/my-library/phpunit.xml.
When I try to run the tests from the command line (outside PhpStorm) vendor/bin/pest
it works like expected.
When I try to run the tests from inside PhpStorm it fails. It doesn’t matter if I try it on a single test function, a file or the whole folder. The error I get is: Test framework quit unexpectedly
/opt/homebrew/bin/php /.../packages/my-library/vendor/bin/pest --teamcity --configuration /.../packages/my-library/phpunit.xml /.../packages/my-library/tests/Unit/ReplyKeyboardTest.php "--filter=/^P\\Packages\\my-library\\tests\\Unit\\ReplyKeyboardTest::it\screates\svalid\sJSON(\swith\s((data\sset\s\".*\")|(\(.*\)(\s#\d+)?)))?$/"
Testing started at 20:26 ...
Pest 1.21.2
Pest\Exceptions\ShouldNotHappen
This should not happen - please create an new issue here: https://github.com/pestphp/pest.
- Issue: Test file not found.
- PHP version: 8.1.4
- Operating system: Darwin
at packages/my-library/vendor/pestphp/pest/src/Exceptions/ShouldNotHappen.php:38
34▕ * Creates a new instance of should not happen without a specific exception.
35▕ */
36▕ public static function fromMessage(string $message): ShouldNotHappen
37▕ {
➜ 38▕ return new ShouldNotHappen(new Exception($message));
39▕ }
40▕ }
41▕
+3 vendor frames
4 packages/my-library/tests/Unit/ReplyKeyboardTest.php:10
it("it creates valid JSON", Object(Closure))
Process finished with exit code 1
When I change the Run Configuration for this test and specify the working directory explicitly to be packages/my-library, the framework quits unexpectedly too, but I get no error from Pest. The output is as follows:
/opt/homebrew/bin/php /.../packages/my-library/vendor/bin/pest --teamcity --configuration /.../packages/my-library/phpunit.xml /.../packages/my-library/tests/Unit/ReplyKeyboardTest.php "--filter=/^P\\Packages\\my-library\\tests\\Unit\\ReplyKeyboardTest::it\screates\svalid\sJSON(\swith\s((data\sset\s\".*\")|(\(.*\)(\s#\d+)?)))?$/"
Testing started at 20:30 ...
Pest 1.21.2
PHPUnit 9.5.19 #StandWithUkraine
Tests:
Assertions: 0
Time: 0s
Process finished with exit code 0
For readability and privacy I shortened the paths to the project root.
I’m not sure how I can fix this. Any ideas?
Issue Analytics
- State:
- Created a year ago
- Comments:21 (10 by maintainers)
Yaaay! 🎉
Alright, I’ll try and clean it up a bit and then hopefully in the next week or two have time to tag v1.4.0 💯
Thanks for your help, it’s really nice when people are willing to help out solving the issue
Haha oops, my bad…
Alright, so lets try again again again… 😅
I have now done so if you have a custom working directory defined that is used, else the the parent dir of phpunit.xml is used PEST PHP-1.3.1-EAP.8.zip