【发布时间】:2011-12-19 11:35:44
【问题描述】:
如何对 hitTest 覆盖进行单元测试?
- (UIView*) hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView* hitView = [super hitTest:point withEvent:event];
// Do something based on hitView's properties
}
我面临的问题是UIEvent 没有公共构造函数,因此我无法创建UIEvent 以在[super hitTest:point withEvent:event] 上产生不同的结果。
或者,我可以创建一个模拟 UIEvent,但这意味着知道 [super hitTest:point withEvent:event] 用它做什么,而我不知道,即使我知道,它也可能会改变。
另一种选择是混合[super hitTest:point withEvent:event](与OCMock),但我不知道是否可以只混合超类实现。
【问题讨论】:
标签: iphone ios unit-testing hittest ocmock