Mathieu Suen | 8 Dec 2009 16:15
Favicon
Gravatar

Customize phpunit output

Hi,

I would like to customize the output of phpunit.
One way could be to make a subclass of PHPUnit_TexUI_ResultPrinter but
I have no clue on how to inject the subclass.
Any idea?

Thanks

-- Mathieu Suen

Ionut G. Stan | 9 Dec 2009 18:54
Picon
Gravatar

Re: Customize phpunit output

Hi,

The most simple way, in my opinion, is to extend PHPUnit_TextUI_Command, 
override PHPUnit_TextUI_Command::main() and then use this new class in 
the PHPUnit executable.

PHPUnit_TextUI_Command2::main() will be the place where you'll 
instantiate your custom printer.

I've attached the files I used to test this idea. I believe you'll know 
where to place each one of them. Anyway, the class files should be in 
the include_path and the phpunit executable should be replaced.

After that, just run some unit tests and you'll see something like this 
in the output:

F:\projects\php\php-utils\tests>phpunit
PHPUnit 3.4.2 by Sebastian Bergmann.

......................................................F

  -----------------------------------------------------
  Custom PHPUnit printer
  -----------------------------------------------------

On 12/8/2009 5:15 PM, Mathieu Suen wrote:
> Hi,
>
> I would like to customize the output of phpunit.
> One way could be to make a subclass of PHPUnit_TexUI_ResultPrinter but
(Continue reading)


Gmane