This question has very few views and no answers yet. If you have a suggestion what to change about this question to get more eyeballs, I'd be happy to hear them. Cheers!
I'm using GHAsyncTestCase
to test a custom NSOperation
of mine. I'm setting the test case as a delegate on the operation object and I'm calling didFinishAsyncOperation
on the main thread when it's done.
When an assertion fails it throws an exception, which ought to be caught by the test case to render the test as "failed". But instead of this expected behavior, my app get's aborted by Xcode as soon as the assertion fails.
*** Terminating app due to uncaught exception 'GHTestFailureException', reason: ''NO' should be TRUE. This should trigger a failed test, but crashes my app instead.'
I'm obviously doing something wrong. Who can tell me?
@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