这个问题的观点很少,也没有答案。如果你有什么建议要改变这个问题以获得更多的眼球,我会很高兴听到它们。干杯!
我在用着 GHAsyncTestCase
测试一个自定义 NSOperation
我的。我将测试用例设置为操作对象的委托,我正在调用 didFinishAsyncOperation
完成后在主线程上。
当断言失败时,它会抛出一个异常,应该被测试用例捕获,以使测试“失败”。但是,一旦断言失败,我的应用程序就会被Xcode中止,而不是这种预期的行为。
***由于未捕获的异常'GHTestFailureException'而终止应用程序,原因:''NO'应该为TRUE。这应该会触发测试失败,但会导致我的应用崩溃。
我显然做错了什么。谁能告诉我?
@interface TestServiceAPI : GHAsyncTestCase
@end
@implementation TestServiceAPI
- (BOOL)shouldRunOnMainThread
{
return YES;
}
- (void)testAsyncOperation
{
[self prepare];
MyOperation *op = [[[MyOperation alloc] init] autorelease];
op.delegate = self; // delegate method is called on the main thread.
[self.operationQueue addOperation:op];
[self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
}
- (void)didFinishAsyncOperation
{
GHAssertTrue(NO, @"This should trigger a failed test, but crashes my app instead.");
[self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testAsyncOperation)];
}
@end