phpunitHow to log to the console with PHPUnit?
Logging to the console with PHPUnit is possible using the write
method of the PHPUnit_TextUI_ResultPrinter
class.
Example code
$printer = new PHPUnit_TextUI_ResultPrinter();
$printer->write("This is a log message");
Output example
This is a log message
The code consists of two parts:
- Creating an instance of the
PHPUnit_TextUI_ResultPrinter
class:
$printer = new PHPUnit_TextUI_ResultPrinter();
- Writing a log message to the console using the
write
method of thePHPUnit_TextUI_ResultPrinter
class:
$printer->write("This is a log message");
For more information, please refer to the PHPUnit documentation.
More of Phpunit
- How to skip a PHPUnit test?
- How to run tests in parallel with PHPUnit?
- How to use hooks in PHPUnit?
- What are PHPUnit required extensions
- How to use the PHPUnit Framework TestCase?
- How to run PHPUnit in quiet mode?
- How to show warnings in PHPUnit?
- How to load fixtures with PHPUnit?
- How to use a listener with PHPUnit?
- How to stop PHPUnit on failure?
See more codes...