'Laravel - Test with Artisan seed fails
I am trying to be able to load seed data inside of a Laravel test case but I keep encountering the error below.
<?php
namespace Tests\Feature;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class MagicTest extends TestCase
{
protected function setUp(): void
{
Artisan::call('db:seed');
}
public function test_show()
{
echo 'hi';
}
}
But when I try by running php artisan test
RuntimeException
A facade root has not been set.
at vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:334
How can I make this work? Or should I be taking a completely different approach?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
