SimpleTest – PHP unit tester

SimpleTest (PHP unit tester) is a PHP unit test and web test framework. Users of JUnit will be familiar with most of the interface. The JWebUnit style functionality is more complete now. It has support for SSL, forms, frames, proxies and basic authentication. The idea is that common but fiddly PHP tasks, such as logging into a site, can be tested easily.

Amongst software testing tools, a unit tester is the one closest to the developer. In the context of agile development the test code sits right next to the source code as both are written simultaneously. In this context SimpleTest aims to be a complete PHP developer test solution and is called “Simple” because it should be easy to use and extend. It wasn’t a good choice of name really. It includes all of the typical functions you would expect from JUnit and the PHPUnit ports, and includes mock objects.

What makes this tool immediately useful to the PHP developer is the internal web browser. This allows tests that navigate web sites, fill in forms and test pages. Being able to write these test in PHP means that it is easy to write integrated tests. An example might be confirming that a user was written to a database after a signing up through the web site.

The heart of SimpleTest is a testing framework built around test case classes. These are written as extensions of base test case classes, each extended with methods that actually contain test code. Each test method of a test case class is written to invoke various assertions that the developer expects to be true such as assertEqual(). If the expectation is correct, then a successful result is dispatched to the observing test reporter, but any failure or unexpected exception triggers an alert and a description of the mismatch. These test case declarations are transformed into executable test scripts by including a SimpleTest aurorun.php file.

If you want to know more about SimpleTest please visit