我收到了错误
运行命令 ./ vendor / bin / phpunit 时致命错误:Class' TestCase'找不到 第7行/home/vagrant/Code/myapp/tests/ExampleTest.php
。我读到了这个错误并更改了我的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);
}
}
答案 0 :(得分:1)
您应该将命名空间添加到ExampleTest类:
namespace Tests;