如何捕获 OCUnit 测试通过/失败消息/事件

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to stop UIBarButtonItem text from truncating?(如何阻止UIBarButtonItem文本被截断?)
NSURLSessionTaskPriority seems to be ignored?(NSURLSessionTaskPriority似乎被忽略了?)
How to make dataWithEPSInsideRect vector rather than bitmap in vector format?(如何用EPSInside Rect将dataWithEPSInside Rect变成矢量而不是位图的矢量格式?)
How to fix ‘TIC SSL Trust Error’ in iOS?(如何修复 iOS 中的“TIC SSL 信任错误?)
How to use NSURLConnection to connect with SSL for an untrusted cert?(如何使用 NSURLConnection 与 SSL 连接以获得不受信任的证书?)
How to compare objects using operator lt; or gt; in Objective-C?(如何使用运算符 lt; 比较对象或gt;在Objective-C中?)