I'm trying to write some Laravel factories
so that we can seed all tables upfront and also use them for tests.
I'm not very experienced with testing and I have some doubts on which premises should factories be built.
Let's use this simple example, 2 tables:
- users
- notes
Notes have a user_id
field with a FK
.
Should I make the notes
factory to be able to create users
(calling users
factory) or expect that in any test that I try to create notes
I
have already created users
that can be associated with the notes
?
Please give some practical example if you may.