Introduction to PHPUnit

p. !

bq. Testing with PHPUnit is not a totally different activity from what you should already be doing. It is just a different way of doing it. The difference is between testing, that is, checking that your program behaves as expected, and running a suite of tests, runnable code-fragments that automatically test the correctness of parts (units) of the software. These runnable code-fragments are called unit tests.

p. Along the way, the author gives you a small sample class to work with and then helps you understand how to write tests for it. The three page article is in no way comprehensive but if you are not unit testing and wondering what all the hub-bub is about then this is a great article to read. The one interesting part I found was at the end, the author addresses two misconceptions about PHPUnit.

bq. There are two common reasons why people think it is not possible for them to use PHPUnit in their projects. First, they think that because PHPUnit requires PHP 5 they cannot test their legacy PHP 4 code with it. Second, people think that because PHPUnit promotes an object-oriented way of writing the tests it cannot be used to test procedural code.

p. You’ll have to read the article to find the answers to those.

p. This article is short, well written and for the most part uses small words and short sentences. This makes it a great candidate to print out and leave on your managers desk anonymously. Let them read it, have that “Ahh-HA” moment and they can pretend it’s their idea to start unit testing. When it happens, just let them live in their fantasy world.

p. =C=

Published: August 31st, 2006 at 8:40
Categories: News
Tags: , , ,