lundi 29 avril 2019

Proper way to write integration test for Laravel package

So, I need to test Laravel package API endpoints. I'm using Testbench.
Sounded simple enough. Run migrations, seed and make a request using guzzle.

BUT, this package depends on few other packages which all have migrations, not to mention a User model that comes with Laravel. They are all part of a larger application that acts as a dashboard.

First problem is running migrations since the packages are using loadMigrationsFrom() method and I guess their ServiceProviders are not read or executed when testing and Testbench is working differently from Laravel migration loader.

Manually calling artisan migrate before or after "main" migration doesn't work because they intertwine by timestamp.

My idea:
Only run unit tests in isolation.
Write integration test to be run as part of the "main app" installation when all models and migrations are present.

Does this make sense? Is there a better way to write and run these tests?

Aucun commentaire:

Enregistrer un commentaire