Swift 4.1 Conditional Conformance in Unit Tests

April 24, 2018 | Swift, Generics, Architecture, iOS, macOS, tvOS, watchOS

In this tutorial, we'll look at a case study of using conditional conformance in unit tests. The problem we'll be solving is a common one. You have a set of stubbed JSON responses and you want to test that they are serialized correctly into Swift model types. Some responses return a single model resource while others return a collection.