Skip to content
Advertisement

Error when running multiple PHPUnit Tests in Laravel 8

Unit testing in a Laravel 8 project is throwing an error when more than one test is called. The issue is causing my tests to fail when I run more than one at once. When running a batch of tests the first one runs and passes as expected, Then all subsequent tests fail when trying to run the createApplication() function from the default trait CreatesApplication. All of my tests have been run individually and pass.

Causing this error:

JavaScript

This occurs when the two tests run are identical.

So this code:

JavaScript

Gives this result:

JavaScript

Is there a fix I am missing?

Edit, Added App file as requested

JavaScript

Advertisement

Answer

Because you run require_once, the script isn’t loaded a second time and will therefor return a boolean. Replace require_once with require to solve it.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement