Jazz up your phpunit test results

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

Related posts:

  1. Apache mod_rewrite on Windows
This entry was posted in PHP. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>