Version 0.5.1
Last updated 10th February 2006
  • PHPUnit2
  • Fix to Formatter when trying to pick up original exception, provided by Glen Ogilvie.
  • Added comments to Formatter to document the functionality.
  • Initial version.


I’ve recently begun to get into using Test Driven Development in almost everything I can at the moment. However having been spoilt slightly by CFCUnit and JSUnit with their HTML GUIs I found the text runner in PHPUnit2 to be lacking for my personal needs and taste.

After a bit of searching I could not find any existing HTML Runners for PHPUnit2. But along with an article on writing custom runners, some digging in the PHPUnit2 API and taking inspiration from the interface of CFCUnit I created the PHPUnit2 HTML Runner.

This is a simple GUI for PHPUnit2 and provides the following functionality:

  • instant visual feedback for test(s)
  • run multiple test cases and/or test suites at once
  • extra information for test errors and failures
  • history of recently performed tests
  • execution time for each individual test (requires PEAR Benchmark package)

Installation & Usage

Download the zip file and unzip to a web browsable directory on your machine (such as ‘HTMLRunner’) and browse to the directory (e.g. http://localhost/HTMLRunner/index.php).

You will be presented with the homepage which contains the form for entering the tests to run and some basic instructions.

Running multiple tests with PHPUnit2 HTML Runer

Test cases and suites are defined by providing the path and name of the file (without the .php extension), with each test on a new line. The runner will assume the name of the file is also the name of the test case/suite to run, e.g. ‘util/HistoryTest’ will contain a test case class of ‘HistoryTest’.

Example Usage


In this example the util/HistoryTest.php and fake/fake_pathTest.php test cases which are part of the HTML Runner will be run along with the PHPUnit2 test test/PHPUnit2/Tests/OneTestCase.php which is installed in the PEAR/test directory with the standard PHPUnit2 installation. Note that the util/HistoryTest test case requires that the util directory is writable to run.


The results use a combination of colour coding, icons and plain text to enable easy identification of the results of the test(s).

Results display for multiple tests with PHPUnit2 HTML Runner

Firstly an overall status of all the tests performed is displayed in plain text along with the total tests performed, tests with errors and tests that failed. This overall status message is re-enforced by use of a coloured bullet point (see below).

Each individual test case is then presented with an overall status for that test using a coloured bullet point, plain text of the status and numbers for total tests performed, errors and failures. Each test is then presented with its name, execution time (if PEAR Benchmark package is present), test status – represented by icon and plain text – and any assertation messages.

The coloured bullet points, used for the overall status of all the tests and the individual test cases, are as follows:

Test(s) were successful
Test(s) caused one or more errors
Test(s) failed

Extended Detail

For each test that failed extended detail is included, which is linked from the assertation message in the test results for quick navigation to the extended detail.

The extended detail is separated out into a section for each individual test case and then each test failure contains:

  • test name
  • line of test within the test case
  • assertation function used in test
  • assertation message
  • original caught exception message

This is intended to aid in the debugging of test failures and this extra detail has proved quite useful to myself so far and is very similar to the experience that CFCUnit provides me.

Extended exception detail for failed test

Known Issues

Please note the following quirks of the current version of the PHPUnit2 HTML Runner:

  • If any of the paths or filenames provided do not point to a test case/suit file that can be included by PHP no attempt to run those test cases will be made, furthermore no details of un-included test cases will not currently be provided in the results.
  • Unlike the text runner provided with PHPUnit2 the HTML Runner will not attempt to validate the syntax of a test file or related files. This is an intended feature as it is currently only really viable to check whether file is syntaxually valid PHP or not, whereas I would prefer to know the exact errors. This means that any errors/exceptions which are un-caught will be output to screen and may cause the runner to fail. I would recommend enabling display_errors and setting the reporting level to E_ALL for the runner.
  • When tests are in a seperate folder to the class definition they are testing the test will fail if the class definition being tested has any relative includes/requires within it. Reported 2006-03-01 by Glen Ogilvie

Next Steps

Leave a Tip

If you find this code useful you can leave a donation towards the continued development & support.


There have been 28 comments so far, join the discussion.

1. Glen Ogilvie - 1st Mar 2006 - 7:11 am


I’ve found a few bugs with HTML Runner, How would you like me to submit them to you, and also, probally patches to fix them.


2. Dave - 1st Mar 2006 - 9:34 am

Glen – Thanks for your feedback, I probably should implement a formal way to submit patches. But until then I’ll just contact you directly.

3. Bryan Maynard - 26th Apr 2006 - 9:28 pm

Awesome utility, thanks! I am having a problem though. . . I’m new to PHPUnit2 and am trying to setup a TestSuite. For the life of me I can’t get HTMLRunner to work with my TestSuite. When I run the test I get this:
MainSuite Warning 0.0016 failure No tests found in MainSuite

My MainSuite class looks like this:



Any help would be greatly appreciated, thanks again.


4. Bryan Maynard - 26th Apr 2006 - 9:30 pm

Well, that chopped up my code. . .
I was just wondering if you could perhaps give me an example of a TestSuite that works with HTMLRunner.



5. Dave - 27th Apr 2006 - 6:34 pm

Bryan, I’m glad that you like the HTMLRunner. It’s a shame that you can’t get it working with your TestSuite, I’ll take a look at getting an example of a TestSuite implementation for the HTMLRunner together over the next couple of days.

6. icesyc - 18th Jul 2006 - 12:53 am

perfect work!
that is what I want.

7. Sebastian Bergmann - 10th Sep 2006 - 10:47 am

Would you be interested in maintaining your HTML test runner as part of the official PHPUnit package?

8. Dave - 10th Sep 2006 - 6:34 pm

I would be interested in maintaining the HTML test runner as part of the official package, as there are some things I wanted to add but couldn’t initially get to work.

I’ll get in touch directly via email to discuss the possibility of this further.

9. Ben Cornwell - 13th Nov 2006 - 10:28 pm

I’ve been able to get HTML Runner to correctly parse & run all the tests in a test suite – only problem seem to be picking up phpunit output.

(IE, I can see the tests have run:

< snip >
. Time: 1.984030 OK (49 tests)
Test results : success
< /snip >

but no individual results are visible in the ouptut table.

Will keep working at it though – will post back any progress)

10. Jack Senechal - 6th Feb 2007 - 1:33 am

Any word on an HTML test runner for PHPUnit 3.x? I see that it has been added to the list for the 3.1 release, but I can’t find any more info.

11. Dave - 25th Feb 2007 - 6:08 pm

Sorry for the late response, where did you see mention of a HTML test runner for PHPUnit 3?

I did receive an updated version of my test runner that had been tweaked to work for PHPUnit 3, but I haven’t had time to evaluate it yet.

12. cookie - 15th Mar 2007 - 4:19 am

Thank you for your hard work!! But there are some problems,such as it doesn’t have a guidebook;if my test cases failed,I just get a blank screen!
Desired for your answer!
Thank you again!

13. Jack Senechal - 12th Apr 2007 - 4:14 pm

Hi Dave,

Sorry, I didn’t get an email about your response… just checking back in now. I saw the 3.1 roadmap comment on Sebastian’s blog –

However if you look at the tickets in Trac, it appears it’s been moved off to 3.2. If you have a version that works with PHPUnit 3 I would be very interested to get a copy. Thanks!


14. Holyghost - 20th Apr 2007 - 7:52 am

Can you help me? I cannot see the button “Run Test” and link “Test History”, can anybody will solve this one?

[…] To have a nice GUI available also outside the world of TYPO3 I migrated the Ideas of Robert and Kasper to PHPUnit_CoolUI. Another source inspiration is, PHPUnit2 HTML Runner from Dave Spurr (UK). Unfortunately it depends on an older version of PHPUnit, so that I didn’t get it running. […]

16. Xcode - 22nd Jul 2008 - 4:25 am


This is simply supurb, but i have one question. I am using phpunit and my test cases includes lots of curl calls and so many other code which consume more time. Let function test_1() will take 1 minutes test_2() will take 2 or 3 minutes or so on, so i am running 60 to 100 test cases in a class, so i have to wait for an hour or more to get my result to be displayed. Is there any way to display the result of test cases as soon as one test case is finished? So that we can see step by step execution results of tests.

Need is here, as some times some connectivity issue may be there due to which all my test cases are going to fail, so if i can makeout the failure from my first or second test case, so i can stop wasting my time and stop the execution and debug the issue :-)

Thanking you and waiting for the reply.. (I can take care of the maximum execution time limit in PHP.ini)


17. Dave - 22nd Jul 2008 - 8:07 am

I’m not sure about that, surely having tests that take an hour to run is not a good idea anyway. Calling external services is something you should be mocking out in your tests so your tests won’t take as long and won’t have to deal with an unknown quantity. E.g. instead of doing the curl you’ll have tests where that is mocked out for both successful and unsuccessful responses that are easy to test against in a consistent fashion.

18. Xcode - 22nd Jul 2008 - 9:00 am

Thanks for your sggestion. For telling sake i just told it will take one hour. But any way its taking more than 15 minutes. And i can’t avoid the the curl calls as i am doing Webservice testing, as its so convenient. And its for sure that the curl calls will take some time depends on the network :(

My need is just to print the result of the testcase as soon as its finished executing. Here its happening only after the execution of the last test case.


19. Dave - 22nd Jul 2008 - 10:33 pm

Yeah from what I remember (I currently don’t have PHP setup in my environment) it stores all the results up and then does the display. I suppose you could use some sort of output buffering and release that to the browser as you go, but that would be quite a change to what I have, maybe using my code as a base will help.

Sorry I can’t offer anything more substantial than that.

20. Xcode - 23rd Jul 2008 - 4:09 am

Thank you once again for your reply, Dave. Will try to do in that way…

21. Elijah Insua - 31st Jul 2008 - 11:42 am

Looks good! Great minds must think alike because I have built a similar project! Mine however is completely ajax’d and can use a backend of PHPUnit or SimpleTest. It also does a bunch of other nice things such as dependency resolution/caching and hard error bypassing. I’m also planning on adding project support and possibly back ends for other languages! you can check it out here

keep it up!

22. William - 18th Aug 2008 - 9:05 am

Hi, nice job for testing.
However, PhpUnit2 seems to be outdated, do you have a version running with PhpUnit 3.x ?

that would be great !

23. Federico - 3rd Feb 2009 - 3:14 pm

i adapted your code to work with the current phpUnit. Give me your email please so that I can send it to you and you can upload it again.

Best regards and Nice Job!


24. Rossen Zahariev - 13th Feb 2009 - 6:24 pm

Hi ,

I am glad I have stumbled upon you PHPUnit GUI , it is really nice and does
the job!
For those having trouble with the include or require issue , I would suggest to have look for the PHP __autoload , as if can be very useful in that case!

Great job !

25. Valentin Popescu - 8th Jun 2009 - 7:49 am

looks nice, wish i knew about this before making my own . well you can check mine since it’s on bsd license as well, at sourceforge. the project name is phpunitwebui

26. John J Smith - 1st Sep 2009 - 2:00 pm

The screenshots of the test output look good but when I run a test (even one of the provided tests) I just get a blank page. I’ve checked all the file permissions and they look ok. Any idea where I’m going wrong?

[…] for PHPUnit, there’s PHPUnit2HTMLRunner, but it is far from ideal. However, if you’re willing to set up a continuous integration […]

[…] for PHPUnit, there’s PHPUnit2HTMLRunner, but it is far from ideal. However, if you’re willing to set up a continuous integration […]

29. JesKeeft - 29th Nov 2016 - 1:28 am

34hour Canadianpharmacy Propecia Side Effects Lawsuit buy priligy dapoxetine online safely Propecia Doping Receta Medica Propecia Canadian Propecia Soft Propecia Levels Alfacip Kann Man Viagra In Holland Kaufen Acquisto Levitra Game cialis Rhine Inc India Complaints Protonix Without A Rx Espana Comprar Kamagra Oral Jelly Priligy Andorra Precio viagra Super Active Viagra Metformin Order India Amoxicillin Causes Macaw To Vomit viagra Dutasteride 25mg Dapoxetine Achat En Ligne

30. JesKeeft - 7th Dec 2016 - 9:23 am

Buy Amoxicillin Online In The Uk What The Diffencebetween Venlafaxine Viagra Achat Net cialis Acquisto Viagra Per Donne Effet Du Cialis Medicament Baclofene Ou Acheter Du Viagra Librement Where To Buy Cialis Yahoo Propecia Proscar Benign Prostatic Hyperplasia generic cialis Viagra Prezzo Di Vendita Cialis Senza Ricetta Austria Cialis Controindicazioni brand levitra online usa pharmacy How Do A Zithromax Capsule Look Soft Tabs Kamagra Antibiotics Online Overnight Cialis Non Prescription Where to order real isotretinoin drugs on line Cialis Quanti Mg cialis price Cephalexin For Staph Nexium Discount Offer Professional Viagra Generic Buy. Amytryptline Viagra Acquisto Farmacia cheap cialis Ambilfy Without Prescription Buy Celexa Online Order Tadacip Online Amoxicilline Et Angine Rouge Levitra Medicamento Para Impotencia Viagra Without Insurance cialis online Viagra Generico 50 Viagra E Solfatare German Cialis Cialis Naturale In Farmacia online pharmacy Cialis Ayuda Durar Mas Chemical Mechanism Benzene To Amoxicillin Levitra Westen Acheter Sildenafil 120 Mg viagra prescription Cheap Combivent No Prescription Needed Kamagra Vendita In Tunisia Cout Levitra 10 Mg Orodispersible Cialis No Me Hace Nada viagra Cialis Online Preisvergleich Adresse Xenical Sans Ordonnance Finistride 1mg Uk No Prescription Kamagra Oral Jelly Aus Deutschland Kamagra A Buon Mercato viagra online Does The Levitra You Can Buy Online Work The Same Envio De Cialis A Reembolso Viagra Pfizer Acquisto Mdm And Amoxicillin kamagra 100 without prescription Child Dose Amoxicillin Levitra Per Giovani Amoxicillin Is It Penicillin Viagra Se Vende Con Receta Propecia Order Cheap Cialis Rayrx Online Drugstore Priligy Dapoxetine In India Generic Viagra For Sale In Usa Can I Drink Alcohol With Zithromax cialis online pharmacy Buy Viagra 50mg Compare Generic Viagra In Canada Propecia Itchy viagra El Cialis Es Cialis Forma Farmaceutica viagra cialis Propecia Without A Prescription Levitra Cialis Comparison Buy Tamoxifen Nolvadex Viagra 30 Anos levitra 20mg prices Generic Pyridium Best Website With Overnight Delivery Commander Viagra Pour Femme Flibanserin Mail Order Cialis Correct Viagra Dosage Levitra Come Acquistare Non Prescription Viagra Generic viagra cialis Zithromax Duration Trade Generic Name For Amoxicillin Salzarex Gen Amoxicillin 750mg cialis Viagra Pharmacie Marseille Canadian Pharmacy Clonidine Amoxil 250 Mg buy viagra online Cheap Generic Lasix Comment Les Mecs Last Longer Buy Clavamox For Cats Online Topical Propecia Hair Follicle Cialis Generika Per Uberweisung Cheap Viagra Best Price Viagra 100mg Propecia Y Dutasteride Kamagra Acostumbramiento

31. ohzpoxnm - 16th Dec 2016 - 6:57 pm

QzS58k bngttawuutom, [URL=]gmdlimbsgocx[/url], [link=]zujlulijvskn[/link],

32. JesKeeft - 23rd Dec 2016 - 10:02 am

Levitra Capsulas Generic Daily Use Cialis online pharmacy Brand Generic Propecia Cialis Y Levitra Genericos Acquista Viagra Senza Ricetta cialis price Cephalexin Gingivitis Cialis 5 Mg Vademecum Buy Prednisone Without Prescription Edmundo Propecia Cheap Quick Cialis cialis Reosto Cialis Dose Buy Viagra Winnipeg Venta De Viagra En Barcelona buy cialis Amoxicilina Sale Discount Comprar Cialis Disfuncion Erectil

33. Barnypok - 28th Dec 2016 - 7:01 pm


34. Barnypok - 29th Dec 2016 - 9:18 pm


35. Barnypok - 31st Dec 2016 - 11:43 am


36. Barnypok - 4th Jan 2017 - 7:59 pm


37. Barnypok - 5th Jan 2017 - 8:22 am


38. Barnypok - 7th Jan 2017 - 3:07 pm


39. JimmiXzS - 9th Jan 2017 - 12:11 am


Leave a comment

No HTML please, only textile. For code please use [lang]...[/lang] tags (e.g. [html]...[/html] for HTML)