fylzero's avatar
Level 67

Is it possible to run db:seed when using SQLite in memory with phpunit?

I am using use DatabaseMigrations; in my test files to migrate:fresh the database on every test run.

Is there a way to seed the database on every test?

0 likes
1 reply
STEREOH's avatar
STEREOH
Best Answer
Level 18

TestCase has a method (from InteractsWithDatabase trait) for it that simply call php artisan db:seed

combining it with the setUp method you can do this.

public function setUp()
{
    parent::setUp();
    $this->seed();
}

https://laravel.com/docs/7.x/testing#artisan-test-runner just scroll a bit up for the Doc about setUp

Please or to participate in this conversation.