phpunit: Colored output does not work anymore

Since around 4.5 colored output stopped working. It does not matter if it is triggered by phpunit --colors switch in console or colors = "true" in phpunit.xml, the line with result (green/yellow OK / red FAILURE) is not colored which makes it harder to quickly assess tests state. What works though is coloring output of --coverage-text, all lines are working as expected.

I couldn’t find anything in the project documentation, there are no complaints about the issue on StackOverflow and other such places so I’m wondering what happened? I’m using Ubuntu 14.04 and ZSH shell, PHPUnit is installed through Composer.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

To anyone who does not have colors with --colors=auto or colors="true": you need to have posix extension installed.

Thanks for pointers to these issues, but I just noticed another issue: colors are present when PHPUnit is invoked like ./vendor/phpunit/phpunit/phpunit, but not with straight phpunit. In both cases PHPUnit reports latest version 4.6.4. Things get weird when it is invoked using phpunit --colors=always, in this case PHPUnit reports version 3.7.28 (Ubuntu DEB package version) and displays error “option --colors doesn’t allow an argument”.