I'm stuck with an OO issue. I have a simple Unit Test class with which I can do some assertions. For exmaple, my code could look like this:
class TestSomething extends UnitTestCase
{
public function someTest() { ... }
}
An important thing is obviously to log the results of the test to some place. That could be a web page, or just a file or maybe a database.
Currently I need to log to both a file and disply the results in a web browser. But I want to keep my code as extensible as possible. It should be easy to add another type of "logging" mechanism.
So currently my UnitTestCase
class looks like this:
class UnitTestCase
{
protected function printHeader ( $testResults )
{
}
protected function printResults ( $testResults )
{
}
protected function printFooter ( $testResults )
{
}
public function assertSomething() {...}
// ... And alot of other assertions
}
Currently I am not logging anything, because I'm not sure how to continue. What would be a good way to implement different types of logging mechanisms in the UnitTestCase
class and keep the code clean and OO?