Jazz up your phpunit test results

No Responses February 1st, 2009 | Ekerete.

I use RedGreen when working on rails projects and have gotten used to the visual feedback I get when tests pass or fail. It has definitely helped with my Red-Green-Refactor flow.

I just found out phpunit supports colors in tests and it’s built-in as well. No gem installation required. Sweet!
Turning on colours is done either with a command line argument or by adding an attribute to the phpunit XML configuration file.

Command Line:

phpunit --colors testfile.php

XML File:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
	<testsuite name="All Tests">
		<directory>./</directory>
	</testsuite>
</phpunit>
  • No Colours:
    No colour
  • Passing Tests – with colours:
    Passing Tests
  • Failing Tests – with colours:
    Failing Tests
  • Skipped or Incomplete Tests – with colours:
    Skipped Tests

Leave a Reply