Answer the question
In order to leave comments, you need to log in
How do you keep fixtures up to date?
Gentlemen, I ask for advice: a large project, complex logic, actively written. You need to write unit tests, which requires a bunch of fixtures. How do you arrange them and how do you keep them up-to-date?
Writing to arrays in files (as Yii recommends) - we tried it - it's hard to keep up-to-date - we have 5-10 migrations a week, the structure is changing quite actively + the objects themselves are complex, some aggregates are scattered over 10 tables.
Now we are thinking of making a pre-filled base, filling it with objects in different versions. But again, it turns out that every time you need to roll migrations to this base or something ...
There is an idea not to use a pre-filled database, but to create them using code before running tests (create a couple of users, goods, orders, etc.) Here there are fears that it will take a long time + again to support - for example, to bring an order into a certain state - a lot of code is needed ...
In general, how do you support complex fixtures, share your experience!?
I would appreciate your advice, thanks in advance!
Answer the question
In order to leave comments, you need to log in
There is an addition to Gii
from Eliseev,
in particular, it can generate a file with an array of data for the model from the current database
https://github.com/ElisDN/yii2-gii-fixture-generator
- filled it ... and all the fixture
ran out of steam, then again through gii rolled out the current info to the file and you're done :)
Writing to arrays in files (as recommended by Yii) - we tried it - it's hard to keep it up to date - we have 5-10 migrations a week, the structure is changing quite actively + the objects themselves are complex, some aggregates are scattered over 10 tables.
Of course it's difficult. And where does the metric "Write code with tests three times slower" come from?
Maintain code, support tests, support fixtures.
structure is changing rapidly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question