这个问题的观点很少,还没有答案。如果您有关于如何改变这个问题以获得更多眼球的建议,我很高兴听到他们的声音。干杯!
我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