Hey dude, you probably have use Illuminate\Foundation\Testing\RefreshDatabase; in your imports. You can remove it. But it is a nice feature to have, just setup your seeders to mock out a production like database setup and it's really helpful to leave in.
Dec 7, 2017
6
Level 12
Phpunit drops database tables
I'm trying to test my app using phpunit with laravel but each time I run
unit test
vendor\bin\phpunit
All tables in my database drop so I have to migrate each time I run a test
I tried mysql and sqlite and same issue
main database on mysql and test on sqlite
Have you encountered with similar issue & how can I fix it ?
Level 23
an other cool trick I do is - I create a test database (mysql) i seed it normally (by changing .env DB_DATABASE) and then use it in phpunit - this way i dont reseed/refresh it and it drastically speeds up my test - (I use the Transaction Trait in my test so each test is done in isolation & without changing the initial db seed state)
1 like
Please or to participate in this conversation.