Pre-commit hook for behat tests

a couple of months ago

If you are working on small project and you’re using Behat tests, there will be times when you change code and as consequence of that, introduce a bug or break a feature. And more often than that, because we are humans and we forget to do things all the time, you will not run your functional ( in my case Behat ) tests, so bug will go live.

So in order to automate that i created a pre-commit hook that runs Behat test and then rejects commit if they fail.

Git hooks are located in your .git directory and you can have your own bash code executed on every git event you choose, pre or post event.

Feel free to play with this little script and improve it as it pleases your needs.

P.S. If you want to skip this check then you can commit your code with


Anel Bejtović

About the Author

Anel Bejtović

30 year old software developer from Mostar, Bosnia and Herzegovina, currently living and working in Frankfurt am Main, Germany.

Follow Anel Bejtović: