PHP TestFest 2009 - First try

This is a quick report on my first trial as a local group coach for the PHP TestFest 2009 for the PHP Perú group. Assistance: 20 people (all more or less PHP developers, some very fresh) Preparation time: about 6 hours of readings, downloading, slides preparation, etc Teaching time: 2 x 1/2h. First one explaining what are Unit Tests and what they are good for, second one to explain how it was done for PHP, set a PHP sources directory on each machine, compile and get setup, then select the appropriate functions from the gcov functions list (see below) Real practice time: 1h30, with real practical cases of how the test could go wrong (white spaces, names of files, inclusions of files, init section, etc) Results: 4 tests for get_required_files() (duplicated from get_included_files() but separated in various files) and 3 tests for phpversion(). And a lot of new knowledge acquired.

Teaching

We're a Peruvian group, so the slides are in Spanish:

Setting up

We were having the event in my company, which has about 12 computers in a room, all Ubuntus 8.10, so this is mostly valid for an Ubuntu-based setup. As suggested by the TestFest wiki, I downloaded a recent snapshot of PHP 5.3 from http://snaps.php.net/ (and a separate version for Windows) and put it on a shared drive so that everyone could download and compile. On every machine, we untared the package on the Desktop and opened a terminal to get in there, then typed
sudo apt-get install libxml2-dev ./configure ./make
We then looked at http://gcov.php.net/ -> PHP_5_3 -> tested-functions  to get an idea of what functions we could cover (we found it much easier to decide from this list than from the real coverage list) We then copied a few tests from ext/standard/tests/general-functions/ (we chose to use get_included_files() as an example for the tests. These tests seem old and do not respect the one-test-per-file rule, but anyway, it was a good and simple base. In a terminal, we got in the root directory of the PHP untared and compiled package, and set a fundamental element of the tests, the TEST_PHP_EXECUTABLE environment variable, then executed the first test:
export TEST_PHP_EXECUTABLE=./sapi/cli/php ./sapi/cli/php run-tests.php ext/standard/tests/general_functions/get_required_files.phpt
That pretty much gave us direct results on our new tests. We then passed on and developed new tests, and that was it for what I think was the first participation in the PHP TestFest 2009. I hope this helps other people spare time on preparations and focus on tests generation. I will soon be sending the revised tests to the QA team.

Conclusion

To us, this was a good event. Although we didn't produce much, we pretty much al managed to learn from the experience and get to actually do something together, which was great stuff. I'm not sure anyone is going to have much time writing tests during the next weeks (if they do, I will pass them on), but we intend to try again on the 6th of June.