Skip to content
Tate Bosler edited this page Oct 4, 2018 · 2 revisions

If you'll be working on the Mission Control project, chances are you'll be writing some tests to make sure your changes work as expected. We aim to have as much code as possible covered by the Travis tests, with bonus points for Laravel Dusk. Pull requests to the master branch have their test coverage checked by Code Climate.

By default, both Travis and Dusk tests use the same database connection as your main instance of Mission Control. However, since tests make use of Laravel's RefreshDatabase trait, you'll want to create a new database on the same database server. You can define the new database name in phpunit.xml.

As a reminder, Laravel Dusk does not install in production, so you'll want to run Dusk tests in development. When installing to production, be sure to add the --no-dev flag to your Composer install to prevent Dusk from being added.

Travis

The Travis test suite is broken into four groups, each of which is a separate directory under the tests directory:

  • Feature: Feature/integration testing for standard web requests made from a browser. These tests generally verify that controllers behave as expected and that the correct HTTP response (whether it's a redirect or a view) is returned.
  • Unit: Unit tests that verify attributes of single models.
  • API: Feature/integration testing for the API endpoints.
  • Permission: Tests that verify that the permission system is responding correctly. These tests most commonly check for an HTTP 403 response (or lack thereof).

All tests can be run at once with phpunit, or the --testsuite option can be added to run each suite individually.

Dusk

Laravel Dusk is our browser testing engine. To run the Dusk tests (in development or staging, not production!), run php artisan dusk:install, then php artisan dusk.

Dusk tests are stored in tests/Browser, with supporting files found in further subdirectories.

Please note that Dusk tests can take a while longer than standard PHPUnit tests and do not report the same coverage metrics. These tests are mostly focused on testing our JavaScript and Vue front-end packages, as well as Blade.

Clone this wiki locally