在ExampleTest.php中找不到类"Tests \ DuskTestCase" [英] Class 'Tests\DuskTestCase' not found in ExampleTest.php

查看:153
本文介绍了在ExampleTest.php中找不到类"Tests \ DuskTestCase"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行Laravel Dusk测试,但是当我运行测试时,会弹出一个新的Chrome标签,并显示此消息.

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

到目前为止,我所做的只是运行composer require --dev laravel/dusk:^1.0php artisan dusk:install.

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

这是我的ExampleTest.php(正是Laravel设置的方式)

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也和Laravel一样设置,并具有名称空间namespace Tests;.

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

我正在使用Laravel 5.4和Dusk 1.0.我正在通过PhpStorm进行测试,并使用此处.

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

任何人都知道为什么即使似乎已正确设置了DuskTestCase,却还是找不到它?预先感谢.

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

推荐答案

由于使用了不包含以下内容的过时文档,因此出现了此错误:

I had this error due to using out-of-date docs that didn't include this line:

$ php artisan dusk:install

这篇关于在ExampleTest.php中找不到类"Tests \ DuskTestCase"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆