我试图编写单元测试,在其中传递经过模拟的UIView,该UIView已添加到视图层次结构中。这是基本的复制品:
- (void)testUIView {
UIView *realView = [UIView new];
UIView *mockView = OCMClassMock(realView);
UIView *theSuperView = [UIView new];
[theSuperView addSubview:mockView]
}
错误是:
[__NSArrayM superlayer]: unrecognized selector sent to instance 0x7fe0ca43fa00
有人知道我该如何解决吗?需要模拟该视图,因为我想确保在UIView上调用某些方法。