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:
- Passing Tests – with colours:
- Failing Tests – with colours:
- Skipped or Incomplete Tests – with colours:
Related posts: