我试图在laravel单元测试中为我的一个模型创建工厂
use Illuminate\Support\Collection;
use phpDocumentor\Reflection\Types\Parent_;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\User;
use Illuminate\Auth;
use App\Role;
use App\AppName\HolidaysEmployees;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class TestApiCalls extends TestCase
{
public function setUp()
{
parent::setUp();
$this->user = factory(User::class)->create([
'firstname' => 'RA',
'lastname' => 'Tester',
'password' => bcrypt('tester'),
'email' => 'ra@tester.com'
]);
$this->holidays = factory(HolidaysEmployees::class)->make();
}
}
但是当我运行测试时,我却不断得到
InvalidArgumentException: Unable to locate factory with name [default] [App\MyName\HolidaysEmployees].
在这种情况下我该怎么办?
答案 0 :(得分:0)
我发现了如何在线解决此问题:
更改
class TestApiCalls extends TestCase
到
class TestApiCalls extends \Tests\TestCase