mcbates's avatar

How to use model factory as setup in multiple test files?

Almost all my tests need a season (as in sports) to be set to run properly. For example every match needs a season that is assigned to it.

Right now, in nearly all tests, I need to set up factory(Season::class)->create(). My first idea was to use a setup function

function setUp()
{
  factory(Season::class)->create();
  parent::setUp();
}

Or even put in the global setUp() function.

But factories do not work at this stage of application loading, if I understand correctly.

Which other strategy could I use?

0 likes
1 reply
mcbates's avatar
mcbates
OP
Best Answer
Level 4

Turns out setUp() in the single file works out. Must have been a typo.

Please or to participate in this conversation.