在我们之前的应用程序中,使用Laravel 5.3,将processIsolation
设置为false加快我们的测试速度而不会导致任何错误:
phpunit.xml:
<phpunit backupGlobals="false"
...
processIsolation="false"
stopOnFailure="false">
在我们当前的项目中,在laravel 5.4中,将processIsolation
设置为false会导致我们的所有功能测试失败(尽管它们确实更快)(为简洁起见,有些已删除):
5) Tests\Feature\CallsToActionApiControllerTest::testUsers
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
/johnny/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:161
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:533
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:512
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:498
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:174
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
/johnny/vendor/barryvdh/laravel-cors/src/HandleCors.php:34
/johnny/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:148
...
/johnny/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:149
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:234
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:206
/johnny/tests/Functional/CallsToAction/CallsToActionApiControllerTest.php:142
...
7) Tests\Feature\EmailEndpointControllerTest::testCaptureEventsWithBlankRequest
Expected status code 200 but received 404.
Failed asserting that false is true.
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:88
8) Tests\Feature\EmailEndpointControllerTest::testUnsubscribe
Expected status code 200 but received 404.
Failed asserting that false is true.
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:96
9) Tests\Feature\EmailEndpointControllerTest::testUnsubscribeWithAlreadyUnsubscribedEmail
Expected status code 200 but received 404.
Failed asserting that false is true.
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:108
ERRORS!
Tests: 72, Assertions: 79, Errors: 21, Failures: 9.
Script ./vendor/bin/phpunit handling the test event returned with error code 2
它们都是404错误,或NotFoundHttpException错误。
我们之前的工作是laravel 5.3和phpunit 5.5;我们目前的破坏项目是laravel 5.4和phpunit 5.7。我注意到两个laravels之间的一个变化是app.php
中的应用程序URL已从
'url' => 'http://localhost'
到
'url' => env('APP_URL', 'http://localhost'),
但改回来并没有做任何事情。请帮助 - 我们的测试需要10分钟而不是10秒。