Laravel 5:致命错误:Class' TestCase'未找到

时间:2017-08-09 17:33:52

标签: php json laravel laravel-5

我收到了错误

  

致命错误:Class' TestCase'找不到   第7行/home/vagrant/Code/myapp/tests/ExampleTest.php

运行命令 ./ vendor / bin / phpunit

。我读到了这个错误并更改了我的composer.json并添加了TestCase.php文件。但是我仍然遇到这个错误。

我的档案:

composer.json

"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ],
    "psr-4": {
        "Tests\\": "tests/"
    }
}

TestCase.php

<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
   use CreatesApplication;
}

ExampleTest.php

<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ExampleTest extends TestCase
{
/**
 * A basic test example.
 *
 * @return void
 */
public function testExample()
{
    $this->assertTrue(true);
}
}

1 个答案:

答案 0 :(得分:1)

您应该将命名空间添加到ExampleTest类:

namespace Tests;
相关问题