seattlerb/minitest — pull request #297 by calavera (2013-05-26 03:49:51+00:00)
Title: Decouple reporter outputs from report calculations.

The Reporter interface and composition makes it really easy to write custom reporters, it has a problem though. The logic that calculates useful information, like counting the number of tests, is mixed between the methods that write the report outputs.

With this change it's easier to write custom reporters keeping all that logic separated from the real outputs.

For instance, without this change, if I want to write the output that each test generates in a different fashion, keeping the test counting, I'd need to override the `report` method and copy the counting logic, like this:

```ruby
def report result
self.count += 1
self.assertions += result.assertions

io.print "OMG THIS IS A TEST!!! %s#%s = %.2f s = " % [result.class, result.name, result.time]
io.print result.result_code

results << result if not result.passed? or result.skipped?
end
```

With this change, I only need to override the method `print_report`, keeping the counting out of my way:

```ruby
def print_report result
io.print "OMG THIS IS A TEST!!! %s#%s = %.2f s = " % [result.class, result.name, result.time]
io.print result.result_code
end
```