PHP Autotest for Test-driven Development | Блог медиа-лаборатории Креоген

Test Driven Development (TDD) is a software development process based on writing a test before writing any line of code. This methodology is very useful, because it allows you to plan your application’s API while writing tests, and at the end you have two benefits: 1) ready specification for your app, 2) some assurance that your code is well-written.  This methodology requires you to follow these 3 steps repeatedly:

  1. Write a failing test
  2. Write code to pass this test
  3. Refactor your code (while making sure you pass this test)

These three steps are often called “Red, Green, Refactor” because of the test util output.

Every time you make any change to your code you run the tests. That’s why tests run very often.

Developers in Ruby have a tool to automate launch of the tests on each code change. It’s called “autotest”.  You run it before starting new development session and it repeatedly checks state of your files. I tried to find similar tool for PHP and found several tools written in Ruby, JavaScript, Shell, but PHP. So I decided to write my own solution. You can find it on github along with the instructions on how to install and use Autotest for PHP.