测试来自中间件的重定向

I have this test case:

public function testRedirectToAndSetDefaultLocale()
{
    $locale = config('app.locale');
    $this->visit('/')->assertRedirectedTo('/' . $locale);
    $this->assertEquals($locale, app()->getLocale());
}

And the following middleware:

class SetLocale
{
    public function __construct(Application $app, Redirector $redirector, Request $request)
    {
        $this->app = $app;
        $this->redirector = $redirector;
        $this->request = $request;
    }

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @param  string|null $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        $locale = $request->segment(1);

        if (!array_key_exists($locale, $this->app->config->get('app.locales'))) {
            $segments = $request->segments();
            $segments[0] = $this->app->config->get('app.fallback_locale');

            return $this->redirector->to(implode('/', $segments));
        }

        $this->app->setLocale($locale);

        return $next($request);
    }
}

The test case above fails with the following trace:

  A request to [http://localhost:8000/en] failed. Received status code [404]./Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:196
    /Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:80
    /Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:138
    /Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:80
    /Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:61
    /Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/tests/HomepageTests.php:17

I'm assuming that a server is not started or something like that. However I don't know what to do.

Edit:

Here's what I have in my RouteServiceProvider.php:

$locale = $this->app->request->segment(1);
$this->app->setLocale($locale);


$router->group([
    'namespace' => $this->namespace,
    'middleware' => 'web',
    'prefix' => $locale
], function ($router) {
    require app_path('Http/routes.php');
});

And in routes.php:

Route::get('/', [
    'uses' => 'HomeController@index',
    'as' => 'get.index'
]);