M
M
mitaichik2018-01-14 14:06:39
Yii
mitaichik, 2018-01-14 14:06:39

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

3 answer(s)
M
Maxim Fedorov, 2018-01-14
@Maksclub

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 :)

P
Pavel Volintsev, 2018-01-14
@copist

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.

M
Maxim Timofeev, 2018-01-14
@webinar

structure is changing rapidly.

You must have missed the planning stage. It is bad when the structure is actively changing. It is added - it's normal, but then there are no problems, but it changes - it's a "bedulka".
www.yiiframework.com/doc-2.0/ext-faker-index.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question