ios - XCTests for SLComposeViewController -
ios - XCTests for SLComposeViewController -
i trying write unit test cases using xctest slcomposeviewcontroller , couldn't find solution far.any suggestion in terms of approach , code helpful.
my objective test below code using xctest
slcomposeviewcontroller *tweetsheet = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter]; slcomposeviewcontrollercompletionhandler __block completionhandler = ^(slcomposeviewcontrollerresult result) { [tweetsheet dismissviewcontrolleranimated:yes completion:nil]; switch(result) { case slcomposeviewcontrollerresultcancelled: { [self showalertwithtitle:nil andmsg:nslocalizedstring(@"sharing failed", @"workout summary text")]; } break; case slcomposeviewcontrollerresultdone: { [self showalertwithtitle:nslocalizedstring(@"success", @"success") andmsg:nslocalizedstring(@"message shared", @"workout summary share text")]; } break; } };
if want perform asynchronous test, create "expectation" object, object sets expectation asynchronous task completed @ later point in time. in asynchronous tasks completion block, fulfill expectation. finally, in main queue, after initiate asynchronous task, wait expectation fulfilled.
thus, putting together, asynchronous test like
- (void)testsomethingasynchronous { xctestexpectation *expectation = [self expectationwithdescription:@"some description"]; [self dosomethingasynchronouswithcompletionhandler:^{ // whatever tests want // when done, fulfill expectation [expectation fulfill]; }]; [self waitforexpectationswithtimeout:30.0 handler:nil]; }
ios iphone xctest slcomposeviewcontroller
Comments
Post a Comment