All posts tagged “synchronous unit test

comment 0

#54 Stubbing DispatchQueue in unit tests to run tests synchronously

The Dispatching protocol In issue #50 Synchronous Unit Tests I described an approach on how to get rid of waiting for XCTestExpectation to be fulfilled. The approach assumes hiding an asynchronous dispatch of a block/closure of code to a GCD queue behind an abstraction layer called the Dispatching protocol. In the production code you would implement a Dispatcher type like…

comments 4

#50 Synchronous Unit Tests

Asynchronous Expectations Mobile applications are usually multi-threaded. We perform UI operations on the main thread and dispatch heavy tasks (e.g. network requests, JSON parsing, writing to a file on a disk) on background threads. The iOS allows us to use backgrounds threads for example by using Grand Central Dispatch API (GCD), i.e. by performing operations on DispatchQueue objects. Work dispatched…