Ios 发送控制事件的操作不';t在单元测试中工作

Ios 发送控制事件的操作不';t在单元测试中工作,ios,objective-c,unit-testing,Ios,Objective C,Unit Testing,我想在单元测试代码中触发testButton的TouchUpInside事件,但它似乎不起作用 - (void)testAction { UIButton *testButton = [[UIButton alloc] init]; [testButton addTarget:self action:@selector(handleButtonEvent:) forControlEvents:UIControlEventTouchUpInside]; [testBu

我想在单元测试代码中触发testButton的TouchUpInside事件,但它似乎不起作用

- (void)testAction {
    UIButton *testButton = [[UIButton alloc] init];
   [testButton addTarget:self action:@selector(handleButtonEvent:)
     forControlEvents:UIControlEventTouchUpInside];
   [testButton sendActionsForControlEvents:UIControlEventTouchUpInside];
}

只是不知道如何修复这个bug。

@SachinVas我做了单元测试,而不是UI单元测试。没有这个事件,这个方法将永远不会被触发。@SachinVas我做了单元测试,而不是UI单元测试。如果没有该事件,将永远不会触发此方法。