How to deal with test needed a lot of related data
Hello,
I have some doubts about creating models via factories under testing process.
For example I have service desk system with tickets as a main objects and if I want to make any feature test on ticket then I need to:
create ticket by factory
but ticket as we know need assigned person who open ticket so we need to..
create a agent...
but agent to be agent have to has role "agent" so we need to...
-create role for agent
but ticket need to some target person so we need to...
-create client
-creat role for client
-create category for ticket
-assign category for ticket
-create priority
-assign priority
-create states
-assign proper state
-create status
-assign status
-create first event(message)
...
-and of course create assigned company
-create and assign responsible agent for this company
and I cannot avoid all these things in simply test "if client can answer in ticket"
What is a best way to make feature tests in complex (in relations aspect) systems ?
Complex setup methods + seeds before start tests ?
In everything there is no "best way" ... there is way that fits better your need.
Personnaly I should test all the functionalities like 'ukrainian puppets' , for instance, test role creation, then test agent creation on a test role already defined, ...
But it is ok to preparing "recurence" tests? ... I mean previous test prepare some backgroud for next test ...?
Especially that in my opinion (I read on the Internet) important is that make each test independent and run from scratch (run test in transactions).