class CourseTypesTest extends TestCase { public function setUp() { parent::setUp(); Artisan::call('migrate'); Artisan::call('db:seed',['--class' => 'TestDatabaseSeeder ','--database' => 'testing']); } /** * A basic functional test example. * * @return void */ public function test_list_course_types() { $httpRequest = $this->json('GET','/api/course-types'); $httpRequest->assertResponSEOk(); $httpRequest->seeJson(); } public function tearDown() { Artisan::call('migrate:reset'); parent::tearDown(); } }
$PHPunit PHPUnit 5.7.5 by Sebastian Bergmann and contributors.
E 1 /
1 (100%)Time: 2.19 seconds,Memory: 12.00MB
There was 1 error:
1) CourseTypesTest::test_list_course_types ReflectionException: Class
TestDatabaseSeeder does not existD:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Container\Container.PHP:749
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Container\Container.PHP:644
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Foundation\Application.PHP:709
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.PHP:74
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.PHP:63
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.PHP:2292
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.PHP:64
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Container\Container.PHP:508
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Console\Command.PHP:169
D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Command\Command.PHP:254
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Console\Command.PHP:155
D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Application.PHP:821
D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Application.PHP:187
D:\www\learn-laravel\my-folder-api\vendor\symfony\console\Application.PHP:118
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Console\Application.PHP:107
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.PHP:218
D:\www\learn-laravel\my-folder-api\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.PHP:237
D:\www\learn-laravel\my-folder-api\tests\rest\CourseTypesTest.PHP:17ERRORS! Tests: 1,Assertions: 0,Errors: 1.
问题是–class参数中的空格.如果你仔细看看数组’–class’=> ‘TestDatabaseSeeder’到底有空间……这就是问题所在.将其更改为“–class”=> ‘TestDatabaseSeeder’,它应该可以正常工作.