Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class 'Tests\DuskTestCase' not found in ExampleTest.php

I am trying to run Laravel Dusk tests, but when I run the test, a new Chrome tab pops up with this message.

Fatal error: Class 'Tests\DuskTestCase' not found in path-to-project\tests\Browser\ExampleTest.php on line 9

All I have done so far is run composer require --dev laravel/dusk:^1.0 and php artisan dusk:install.

This is my ExampleTest.php (exactly how Laravel set it up)

<?php

namespace Tests\Browser;

use Laravel\Dusk\Chrome;
use Tests\DuskTestCase;
use Laravel\Dusk\DuskServiceProvider;

class ExampleTest extends DuskTestCase
{
    /**
     * A basic browser test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $this->browse(function ($browser) {
            $browser->visit('/')
                ->assertSee('Laravel');
        });
    }
}

DuskTestCase.php is also just as Laravel set it up and has the namespace namespace Tests;.

I am using Laravel 5.4 and Dusk 1.0. I am running the test through PhpStorm, using the work around described here.

Anyone know why DuskTestCase can't seem to be found, even though it appears to be set up correctly? Thanks in advance.

like image 940
Larisa Avatar asked Dec 22 '17 19:12

Larisa


1 Answers

In composer.json:

add "Tests\\": "tests/" in

"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "Tests\\": "tests/"
        }
    },

then, run composer dump-autoload to reload your packages.

like image 114
saee Avatar answered Oct 02 '22 15:10

saee