About the Author

Chris Shiflett

Hi, I’m Chris, a web craftsman making things like Mapalong & Brooklyn Beta with my friends at Analog.


Apache-Test and SimpleTest

I've been answering questions lately on the SitePoint forums - PHP, Advanced PHP Programming, and Web Security.

One topic really caught my attention - How many actually use unit testing?. No, it wasn't the grammatical error that caught my eye but rather the fact that unit testing was being discussed on a PHP forum.

While reading the topic, I realized that there were many PHP developers using SimpleTest. Feeling like the black sheep, I mentioned my admiration for Apache-Test. I also tried to surmize why it isn't as popular in the PHP community as it is in the Perl community:

I'm not sure whether the average PHP developer would feel comfortable using it. Its userbase has traditionally been C, Perl, and mod_perl developers writing Apache modules and web applications that utilize many of the Apache API's hooks, etc. These people are comfortable on a command line and are writing some pretty complex code that needs the level of testing purity provided by Apache-Test.

When asked for an example test, I pointed readers to the Apache-Test demo that Geoff and I created last year.

Marcus Baker, author of SimpleTest, replied with the following:

Would you be willing to help with getting SimpeTest working with Apache-test?

I replied that I'd be happy to, and now Marcus and I are going to be working together to make SimpleTest output a TAP compliant protocol.

As Geoff is fond of saying, "Build it, and they will come." Well, hopfully Marcus and I can help make all of Geoff's work worthwhile, and hopefully the PHP community can catch up with the Perl community in terms of testing.

About this post

Apache-Test and SimpleTest was posted on Mon, 21 Mar 2005 at 03:55:25 GMT. Follow me on Twitter.

6 comments

1.Matthew Weier O'Phinney said:

I've been toying with unit tests for the past 6-9 months, particularly when writing APIs at work. I've tried both PHPUnit and SimpleTest, and currently use SimpleTest if I utilize unit tests at all -- primarily because it's so well documented. I've followed several of your blog entries about using Apache-Test, and am considering trying it out on my next foray into testing.

What I find most difficult about unit tests is getting myself into a position where I can actually do them. Unfortunately, formal process is generally... lacking... on many of the projects I work on, which means that requirements are often changing up to the day of launch. This makes it difficult to get into good testing habits, as I often don't know enough about how the applications I'm programming are supposed to behave to be able to write a test.

That said, when the stars have aligned properly and I *have* been able to build to test, unit tests have been incredibly helpful in getting my APIs working solidly. My biggest gripe has been my inability to test similarly for the actual application -- and this is where I can see Apache-Test filling a wonderful niche. I look forward to seeing how the integration with SimpleTest comes along -- and hope that it's documented as well as SimpleTest has always been.

Mon, 21 Mar 2005 at 04:51:19 GMT Link


2.perrick said:

Looks like I'll have more documentation to translate into french ;-) I'm looking forward to it !

Mon, 21 Mar 2005 at 08:12:46 GMT Link


3.Geoffrey Young said:

it seems like a good match. really, what Apache-Test provides is a framework to build upon - that we added test-more.php was really just a way to give php folks an easy way to use the infrastructure. Simple Test looks to provide lots that is valuable when writing tests, such as mock objects, so joining the two ought to be pretty powerful.

Mon, 21 Mar 2005 at 15:20:37 GMT Link


4.Jim Plush said:

I've justed started to get some free time to start implementing Unit Testing using PHPUnit. I'm finding it a really valuable tool in the enterprise world.

Mon, 21 Mar 2005 at 18:15:51 GMT Link


5.Chris Shiflett said:

Some people have asked whether this will require OOP. As far as I can tell, SimpleTest does, but the bundled test-more.php library that comes with Apache-Test can be used in either OOP or procedural applications.

Thu, 24 Mar 2005 at 06:29:51 GMT Link


6.Geoffrey Young said:

wrt oop, that's part of the beauty of Apache-Test - it sets everything up and lets you choose the testing library. so, if you like oo use a Simple Test-type syntax. if you like procedural tests, use the included test-more.php. or use test-more.php for oo if you like (I do all the time over in perl land). or write your own TAP-compliant library.

none of this matters to Apache-Test, which is just in charge of configuring up apache, starting the server, running your tests, and aggregating the results, and stopping the server in preparation for another run.

Fri, 25 Mar 2005 at 01:03:33 GMT Link


Hello! What’s your name?

Want to comment? Please connect with Twitter to join the discussion.


Work and Books

Analog Essential PHP Security HTTP Developer's Handbook