Reputation:
How to log only failures in an external file, from php unit? I want the complete information, including actual value, expected value, line number etc. Right now I am using fwrite and logging all pass and fail tests into a file, is there a better way to do it?
Upvotes: 4
Views: 4265
Reputation: 317109
See the Chapter on Logging in the PHPUnit Manual.
The "correct" way to do that would be to write a custom Logger and hook that into PHPUnit's Logging API. Or extend PHPUnit's standard Listener to write any errors to file.
You can setup any custom Loggers and Listeners in your phpunit.xml file. See the Appendix in the PHPUnit Manual for the appropriate markup:
An alternative to writing your own logger, would be to just transform the regular HTML output with an XSLT to only provide the errors:
Upvotes: 5