Set up automated test runs with Git hooks
Set up automated Laravel tests with Git pre commit hooks to prevent broken code reaching production.
Lesson Content
Forgetting to run tests before committing is one of the easiest ways to push broken code to production. A pre-commit hook solves this perfectly by running your test suite automatically.
Create a file at .git/hooks/pre-commit to automatically run your test suite any time there’s a commit.
For a Laravel app, this uses the artisan tool:
#!/bin/bash
php artisan test
# If using Docker Compose
#docker compose exec -T phpfpm php artisan test
Note:
docker compose exectries to allocate a TTY (interactive terminal session) by default,...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.