I've recently become a fan of tests being stored alongside the files they test. In a Laravel 10 project, I have numerous Feature tests in the app folder and make them bootstrap the framework by including uses(TestCase::class) at the top of each file.
This approach does not work in Laravel 11.
How to Reproduce
Create a new project with laravel new example-app and use Pest
Adjust ExampleTest.php to include uses(TestCase::class)
Run this test from the three locations below
File stored in tests/Unit/
This works:
File stored in app/
This also works:
Create the folder app/Console/Commands/ and move the test into there
This throws an error exception:
I've attempted to step through the code to narrow down the error. It's pretty deep and possibly thrown from phpUnit. The Laravel 11 project that does not work includes v10.5.15. The Laravel 10 project that does includes v10.5.13.
What Happened
I've recently become a fan of tests being stored alongside the files they test. In a Laravel 10 project, I have numerous Feature tests in the
app
folder and make them bootstrap the framework by includinguses(TestCase::class)
at the top of each file.This approach does not work in Laravel 11.
How to Reproduce
laravel new example-app
and use PestExampleTest.php
to includeuses(TestCase::class)
tests/Unit/
This works:
app/
This also works:
app/Console/Commands/
and move the test into thereThis throws an error exception:
I've attempted to step through the code to narrow down the error. It's pretty deep and possibly thrown from phpUnit. The Laravel 11 project that does not work includes v10.5.15. The Laravel 10 project that does includes v10.5.13.
Sample Repository
No response
Pest Version
2.34.5
PHP Version
8.2.17
Operation System
Linux
Notes
No response