views:

438

answers:

1

I'm trying to use xcodebuild and OCUnit with my Continuous Integration server (TeamCity).

JetBrains offers test observer implementations for boost::test and CppUnit that format test output in a way that TeamCity can interpret. I need to do something similar for OCUnit if I want to use it.

There appears to be a SenTestObserver class in OCUnit but I'm ignorant of how exactly it should be used, and the OCUnit homepage doesn't seem to provide any documentation on the matter.

+4  A: 

You can write your own observer by extending the SenTestObserver class and implementing the notification listeners

  • (void) testSuiteDidStart:(NSNotification *) aNotification
  • (void) testSuiteDidStop:(NSNotification *) aNotification
  • (void) testCaseDidStart:(NSNotification *) aNotification
  • (void) testCaseDidStop:(NSNotification *) aNotification
  • (void) testCaseDidFail:(NSNotification *) aNotification

Then add a "SenTestObserverClass" entry to the Info.plist with the name of your class.

At least in the version of OCUnit I'm familiar with, SenTestObserver is equal parts useful/broken. I just skip it altogether and register for the notifications myself in my own class. (See SenTestSuiteRun.h and SenTestCaseRun.h for the defines of the notification names).

You can use the test and run properties of the notification to access the SenTestSuite and SenTestSuiteRun instances, and the run instance contains the info needed on the actual results.

superfell