phpunitHow to log with PHPUnit?
PHPUnit is a unit testing framework for the PHP language. It can be used to log the results of tests.
To log with PHPUnit, you can use the log
method of the PHPUnit_Framework_TestCase
class. This method takes two parameters: the log message and the optional log type.
<?php
$this->log('This is a log message', \PHPUnit_Framework_TestCase::LOG_INFO);
The output of the above code will be:
INFO This is a log message
The log type can be one of the following constants:
LOG_INFO
LOG_WARNING
LOG_ERROR
LOG_RISK
LOG_EXCEPTION
For more information, please refer to the PHPUnit documentation.
More of Phpunit
- How to test private methods in PHPUnit?
- How to show warnings in PHPUnit?
- How to run tests in parallel with PHPUnit?
- How to clear the PHPUnit cache?
- How to log to the console with PHPUnit?
- How to skip a PHPUnit test?
- How to mock a method with different arguments in PHPUnit?
- How to disable deprecation notices in PHPUnit?
- How to run all PHPUnit tests?
- What are PHPUnit required extensions
See more codes...