Laravel 5 Reseeding the Database for Unit Testing Between Tests Laravel 5 Reseeding the Database for Unit Testing Between Tests database database

Laravel 5 Reseeding the Database for Unit Testing Between Tests


Just run this:

    $this->artisan('migrate:refresh', [        '--seed' => '1'    ]);

To avoid changes to the database persisting between tests add use DatabaseTransactions to your tests that hit the database.


Why not create your own command like db:reset.This command either truncate all your tables or drop/create schema and then migrate.

In your test you then use: $this->call('db:reset') in between your tests