One time migrations and one time few seeders for tests
Hello,
I have some problem with migrating and seeding my DB under testing process - phpunit.
Normally under development process we need a large amount of data in our DB so we have in project over 70 seeders to providing dummy data but for automatic testing we need only 5-6 seeders with sets of data like locations (4 sec needed), settings, predefined alerts and so on.
For tests we have addiitonal DB and for now we do this in steps manually from command line and/or enabling/disabling use DatabaseTransactions (disable trans -> manually run few seeders, enable trans ->run tests)
But we dreaming about some pro and automated solution where always we can run "php artisan test" and everything will configure just in time (migration + few seeders) and then runs tons of our tests :)
No, I have opposite needs. I want to seed one time for serie of tests. If I want to after whole day run 200 tests then I want to write php artisan test and go for coffe (without any manual additional commands). And additionally I want to start on fresh DB and each test should run as separated transaction. Last one need is if I programming in TDD style I dont want run new seeders but just tests to accelerate speed.
I read many topics on laracasts and stackoverflow and prepare mechanism for this placed in TestCase (maybe helps somebody)
Function run first of all and avoid transaction mechanism (data isnt rolled back)
Field migrate is used to avoid do this part of code in every test (only one time)
0 (zero) in statment is used to swith mode - 0 -develop&testing -1- tests on fresh (migrated and seeded) DB
System has few tables with "static" data like paymentMethods, statuses and so on.
I seed them once and all tests are inside transactions.
Maybe you are right but I dont see advantages of your solution in relation to my ... (my is 100x faster because normally one test in my system = 0,2s , one DB refresh = 3-4s) + in many places code is less clean because before I assert something I need to create 5-10 objects which are background in most of cases.
Please don't think that I am some ignorant. I appreciate your vast experience and knowledge. I just don't like to do things just because someone wrote it :)