I'm writing unit tests for a large API using Laravel, my concern is that due the complexity of the system, a single test requires a lot of previous conditions, such having a user, a session, an active area, etc. and since I'm using transactions (to avoid leaving test records in database), I need to create those previous conditions every test function ... and the code is growing pretty fast and tests are not unitary anymore (because I have to check every previous conditions before testing the actual target, ironically doing other unitary tests).
How do you handle such situation? Do you execute your tests in order and keep the state for futher tests? How do you handle mocking?
Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire