Video Lesson: Set up automated test runs with Git hooks

Set up automated test runs with Git hooks

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

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 exec tries to allocate a TTY (interactive terminal session) by default,...

Premium content

Enroll to unlock the full content and all course materials.

👋
Maggie

Log in to start chatting!

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.