You can watch this episode by subscribing to Cocoacasts Plus.

Building a Weather Application From Scratch

Unit Testing With Mock Objects

Stop Writing Swift That Sucks

DISCLAIMER: No Rocket Science Involved

Join 20,000+ Developers Learning About Swift Development

Download the 4 Swift Patterns I Swear By

Earlier in this series, we wrote unit tests for the DayViewModel, the WeekViewModel, and the WeekDayViewModel structs. Writing those unit tests was fairly straightforward. Unit testing the RootViewModel class is a bit more challenging for a number of reasons.

The RootViewModel class asynchronously fetches the location of the device and weather data for a location. To unit test asynchronous operations, we need to take a different approach.

Instant and Unlimited Access
to 400+ Cocoacasts Tutorials


$19 / month

Pay Once a Month
Access to Community
30 Day Money Back Guarantee


$8.25 / month (billed annually)

Pay Once a Year and Save $129
Access to Community
30 Day Money Back Guarantee
Access to All Books

Next Episode "Unit Testing Asynchronous Code"