square/KIF — Issue #104: support for replacing/extending existing logging mechanism
Author: rlgomes
Created: 2012-01-09 22:53:00+00:00
State: open

Wondering if you guys are working on supporting an easy mechanism for others to log the results of a test run in their own format. The main use case would be to output the test results in a junit xml format and then your CI environment (ie hudson,jenkins) can easily pick up the junit xml and report your results nicely within hudson.

I can put together an initial implementation of such a feature but I'm not a strong objective C developer so I'm going to do the easiest thing which is to allow others to override the following methods from the KIFTestController:

- (NSFileHandle *)_logFileHandleForWriting;
- (void)_logTestingDidStart;
- (void)_logTestingDidFinish;
- (void)_logDidStartScenario:(KIFTestScenario *)scenario;
- (void)_logDidSkipScenario:(KIFTestScenario *)scenario;
- (void)_logDidSkipAddingScenarioGenerator:(NSString *)selectorString;
- (void)_logDidFinishScenario:(KIFTestScenario *)scenario duration:(NSTimeInterval)duration
- (void)_logDidFailStep:(KIFTestStep *)step duration:(NSTimeInterval)duration error:(NSError *)error;
- (void)_logDidPassStep:(KIFTestStep *)step duration:(NSTimeInterval)duration;

and that way you can easily create output the results in whatever format you want while still calling the super.xxx method so that things log to the console as before.

I can also extract those methods in to their own class KIFTestReporter and then have the base implementation which just logs to the console and in the KIFTestController allow the user to register additional reporters that respect the same interface.

Let me know what you think is the best approach, before I fork and start hacking