Because a view model isn't or shouldn't be coupled to the user interface, it's easy to write unit tests for a view model. I'd like to illustrate that in this episode by writing a handful of unit tests for the DayViewModel
struct. If you're new to unit testing, then this episode is an excellent start.
Subscribe to Cocoacasts Plus to watch this episode.
Building a Weather Application From Scratch
Writing Unit Tests for the Day View Model
by Bart Jacobs in Swift
Swift 4
Xcode 9
iOS 11
Building a Weather Application From Scratch
-
03:30
-
07:15
-
12:08
-
05:59
-
07:54
-
13:09
-
13:56
-
12 Organizing Fonts and Colors
06:45
-
13 Implementing the Day View Model
15:55
-
14 Writing Unit Tests for the Day View Model
12:57
-
15 Implementing the Week View Model
12:37
-
20 Efficiently Refreshing Weather Data
08:48
-
09:40
-
22 Unit Testing With Mock Objects
10:49
-
23 Unit Testing Asynchronous Code
06:40
-
08:28
-
25 Exposing Gaps in the Test Suite
04:00