如何捕获OCUnit测试通过/失败消息/事件 [英] How do I trap OCUnit test pass/failure messages/events

查看:196
本文介绍了如何捕获OCUnit测试通过/失败消息/事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的持续集成服务器中使用xcodebuild和OCUnit( TeamCity )。

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

JetBrains提供了用于boost :: test和CppUnit的测试观察器实现,它以TeamCity可以解释的方式格式化测试输出。我需要为OCUnit做类似的事情,如果我想使用它。

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.

在OCUnit似乎有一个SenTestObserver类,但我不知道如何确切地应该而且 OCUnit首页似乎未提供有关此问题的任何文档。 / p>

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.

推荐答案

您可以通过扩展SenTestObserver类和实现通知侦听器来编写自己的观察者

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

  • :(NSNotification *)aNotification

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

然后向info.plist SenTestObserverClass添加一个条目名称。

then add an entry to the info.plist SenTestObserverClass with the name of your class.

至少在OCUnit的版本中我熟悉SenTestObserver是等于零件有用/等于零件损坏。我只是跳过它,并在我自己的类注册通知自己。 (请参阅SenTestSuiteRun.h和SenTestCaseRun.h了解通知名称的定义)。

At least in the version of OCUnit i'm familiar with SenTestObserver is equal parts useful/equal parts 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).

您可以使用通知的测试和运行属性访问SenTestSuite和SenTestSuiteRun实例,并且运行实例包含实际结果所需的信息。

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.

这篇关于如何捕获OCUnit测试通过/失败消息/事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆