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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -