How do I trap OCUnit test pass/failure messages/events(如何捕获 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 主页 似乎没有提供任何有关此事的文档.
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
- (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 测试通过/失败消息/事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何捕获 OCUnit 测试通过/失败消息/事件


- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01