forked from kiwi-bdd/Kiwi
-
Notifications
You must be signed in to change notification settings - Fork 0
Asynchronous Testing
MattesGroeger edited this page Mar 18, 2012
·
7 revisions
Specs | Expectations | Mocks and Stubs | Asynchronous Testing
It's very common for iOS applications to have components that collaborate with the main thread via background threads. Towards this end, Kiwi supports asynchronous testing, thus enabling integration tests - testing multiple objects collaborating together.
This will block until the matcher is satisfied or it times out (default: 1s)
context(@"Fetching service data", ^{
it(@"should receive data within one second", ^{
[[LRResty client] get:@"http://www.example.com" withBlock:^(LRRestyResponse* r) {
NSLog(@"That's it! %@", [r asString]);
fetchedData = [r asString];
}];
[[expectFutureValue(fetchedData) shouldEventually] beNonNil];
});
});This blocks for two seconds instead of the default one second.
[[expectFutureValue(fetchedData) shouldEventuallyBeforeTimingOutAfter(2.0)] equal:@"expected response data"];