You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm noticing some large differences between the printed stack traces when running tests with the phpunit command and php artisan test, using the verbose flag.
Most of the time i'm running php artisan test but the exception stack trace is not helpful at all. I'm not seeing application code in the stack lines, so I cannot figure out the origin of the exception in my code.
When running php artisan test -v:
• Tests\Feature\ExampleTest > example
PHPUnit\Framework\ExceptionWrapper
Attempted to lazy load [posts] on model [App\Models\User] but lazy loading is disabled.
at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:559
555▕ if (! $this->exists || $this->wasRecentlyCreated) {
556▕ return;
557▕ }
558▕
➜ 559▕ throw new LazyLoadingViolationException($this, $key);
560▕ }
561▕
562▕ /**
563▕ * Get a relationship value from a method.
1 vendor/phpunit/phpunit/src/Framework/TestCase.php:904
PHPUnit\Framework\TestResult::run()
2 vendor/phpunit/phpunit/src/Framework/TestSuite.php:673
PHPUnit\Framework\TestCase::run()
3 vendor/phpunit/phpunit/src/Framework/TestSuite.php:673
PHPUnit\Framework\TestSuite::run()
4 vendor/phpunit/phpunit/src/Framework/TestSuite.php:673
PHPUnit\Framework\TestSuite::run()
5 vendor/phpunit/phpunit/src/TextUI/TestRunner.php:673
PHPUnit\Framework\TestSuite::run()
6 vendor/phpunit/phpunit/src/TextUI/Command.php:144
PHPUnit\TextUI\TestRunner::run()
7 vendor/phpunit/phpunit/src/TextUI/Command.php:97
PHPUnit\TextUI\Command::run()
8 vendor/phpunit/phpunit/phpunit:98
PHPUnit\TextUI\Command::main()
When running phpunit -v:
Tests\Feature\ExampleTest::example
Illuminate\Database\LazyLoadingViolationException: Attempted to lazy load [posts] on model [App\Models\User] but lazy loading is disabled.
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:559
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:518
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:453
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2172
app/Actions/ExampleAction.php:122
app/Actions/ExampleAction.php:61
app/Jobs/ExampleJob.php:201
app/Jobs/ExampleJob.php:117
app/Jobs/ExampleJob.php:85
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
vendor/laravel/framework/src/Illuminate/Container/Util.php:41
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
vendor/laravel/framework/src/Illuminate/Container/Container.php:651
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:128
vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141
vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:132
vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:124
vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141
vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116
vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:126
vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:70
vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:98
vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php:43
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:253
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:229
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:77
vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338
tests/Feature/ExampleTest.php:646
Here the stack trace is much more evident, I can see which parts of my code caused the exception, so I can pinpoint my mistakes.
The text was updated successfully, but these errors were encountered:
I'm noticing some large differences between the printed stack traces when running tests with the
phpunit
command andphp artisan test
, using the verbose flag.Most of the time i'm running
php artisan test
but the exception stack trace is not helpful at all. I'm not seeing application code in the stack lines, so I cannot figure out the origin of the exception in my code.When running
php artisan test -v
:When running
phpunit -v
:Here the stack trace is much more evident, I can see which parts of my code caused the exception, so I can pinpoint my mistakes.
The text was updated successfully, but these errors were encountered: