If I dispatch_asyncblock in the main queue:
-(void) myTask {
dispatch_async(dispatch_get_main_queue(), ^{
[self.service fetchData];
});
}
In unit test, I can execute the block passed in the main queue, manually start the main loop as follows:
-(void)testMyTask{
[myObj myTask];
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
...
}
Now I have another similar function that sends a block to the next queue , different from :
-(void) myTask2 {
dispatch_async(dispatch_queue_create("my.sequential.queue", NULL), ^{
[self.service fetchData];
});
}
In unit test, how can I execute a block manually now?
-(void)testMyTask2{
[myObj myTask2];
}
=== Refine ===
, , , - Wait-For-Timeout. , . , ( , ), .