question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test file not found, when not run in root

See original GitHub issue

I 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:closed
  • Created a year ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
olivernybroecommented, Mar 25, 2022

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

1reaction
olivernybroecommented, Mar 25, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

File not found when located in "Test Resources Root"
I have built a special project/module to "reduce" the error in a totally clean setting to make sure that I don't miss something,...
Read more >
How can I test if a file in /root exists without su to root?
I won't work like that,just think about how to judge a root's fiile without su to root.And I find the command test ,it...
Read more >
Testing with pytest always issues a file not found error #6548
Whenever I run the tests, I always getting this strange error: Detail: Unable to read file (Error: File not found
Read more >
How to fix a "Command not found" error in Linux - Red Hat
1. Include the path ... Not everything you want to execute needs to be in your path. You can execute files directly by...
Read more >
How to check if file does not exist in Bash - nixCraft
This page explains how to find a regular file under the Linux or Unix-like system using Bash. Tutorial details. Difficulty level, Easy. Root...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found