GHAsyncTestCase Hangs After notify:kGHUnitWaitStatusSuccess

125 views
Skip to first unread message

dave morris

unread,
Jun 29, 2011, 9:33:49 AM6/29/11
to GHUnit
I have a GHUnit Async test case called
"testStartConnectionWithRequest" that does the following:

* Makes an HTTP request with the test class itself as the delgate
* Calls connectionDidFinishLoading when the request is complete
* Calls another custom callback function at the end of
connectionDidFinishLoading called

imageServerCallFinishedWithPayload:(NSData *)payload
withError:(BOOL)error
withLocalErrorString:(NSString
*)localErrorString
withExtras:(PayloadExtras *)extras

* Calls [self notify:kGHUnitWaitStatusSuccess
forSelector:@selector(testStartConnectionWithRequest)];

When I run through it and set breakpoints, the code reaches all of the
expected points, and then it hangs on "GHTesting runTestWithTarget".
In the debug sidebar, I see the following:

0 objc_msgSend
.....
3 -[NSAutoreleasePool release]
4 +[GHTesting
runTestWithTarget:selecter:exception:interval:reraiseExceptions:]
5 -[GHTest run:]
6 -[GHUnitIPhoneTestViewController _runTest]
7 -[UIApplication sendAction:to:from:forEvent:]
.....
24 UIApplication Main
25 main

When I call notify:kGHUnitWaitStatusFailure instead of success, in the
same spot in my custom callback, the test case finishes with the
following error:

Name: GHTestFailureException
File: /Users/gabe/Projects/gh-unit/Classes/GHAsyncTestCase.m
Line: 129
Reason: Request finished with the wrong status: 1 != 2


Any thoughts on why this might be happening?

Thanks,
Dave

Ondra Rafaj

unread,
Aug 21, 2013, 9:05:09 AM8/21/13
to ghu...@googlegroups.com
you have to wrap the notify: method in dispatch_async(dispatch_get_main_queue(), ^{ ..... });
Reply all
Reply to author
Forward
0 new messages