Skip to content

Latest commit

 

History

History
98 lines (68 loc) · 3 KB

TESTING.md

File metadata and controls

98 lines (68 loc) · 3 KB

RUNNING THE TEST SUITE

The test suite has three levels: Type, Unit & Integration.

Type tests - also known as Static Analysis - relate to PHPStan tests, served by Larastan for this project.

$ compser test:types
# ... {runs the type tests for the project}

Unit tests relate to PHPUnit based tests, as configured by the PHPUnit config file

$ php artisan test
# ... {runs the unit tests for the project}

Integration tests for this project consist of [Dusk] browser tests.

$ php artisan dusk
# ... {runs the integration tests for the project}

# If the output begins with 'Warning: TTY mode is not supported on {local OS} platform.',
# use the following to avoid the warning & display colours in the CLI output:

$ php artisan dusk --without-tty --colors=always
# ... {runs the integration tests for the project}

Whether the tests use Dark Mode is dependent on the relevant OS settings.

One Time Set-Up

Integraion Tests Set-Up

Make sure the APP_URL variable in the DotEnv file matches the URL used to access the app in a browser locally.

You can set-up an environment specific DotEnv for testing with:

$ cp .env.example .env.dusk.{ENV}
# ... {copies the example DotEnv file to a live copy ignoring values in any other DotEnv file
#        where {ENV} is the type of the local environment
#            e.g. `.env.dusk.local`, `.env.dusk.testing`}

Common Test Commands

Type Tests

To run the type tests with a local phpstan.neon file for experimentation use:

$ ./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=2G
# ... {run the types test with the given config}

Unit Tests

$ php artisan test --parallel
# ... {runs all tests in parallel}

$ php artisan test --retry
# ... {runs any tests that failed on the last run first for each test suite}

$ php artisan test --profile --compact
# ... {tests run with minimal reporting because of --compact}
# Top 10 slowest tests:
# ... {shows details about the time taken by those tests because of --profile}

$ php artisan test --filter Controller --bail
# PASS  Tests\Feature\App\...
# ... {acts the same as PHPUnit's `--stop-on-error --stop-on-failure` because of --bail}

Integration Tests

Run the browser test suite with:

$ php artisan dusk
# ... DevTools listening on ws:...
# ... {runs the browser i.e. integration tests for the project}

$ php artisan dusk --stop-on-error --stop-on-failure
# ... DevTools listening on ws:...
# ... {long-form version of --bail}

Prev Next
<<< Contributing <<< .............................. ........................................ >>> Releases >>>