I have a problem running the basic test that ships with Laravel:
app/tests/Feature/ExampleTest.php
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
$this->assertTrue(true);
}
}
When I run it I get the exception NotFoundHttpException
. I can access my website in the browser without problems. This problem appears to apply to all my routes.
Using Laravel 5.4
The route /
is defined in app/routes/web.php
.
It seems that in Laravel 5.4 $baseUrl
property was removed from TestCase
class.
You may add some setUp
to your ExampleTest
:
function setUp()
{
parent::setUp();
config(['app.url' => 'https://myserver']);
}
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.