July 22, 2018 | Swift, Unit Testing, iOS, macOS, tvOS, watchOS
In this tutorial, we'll see how we can use protocols to make custom view subclasses more generic. The benefit is that they'll be easier to test and reuse, and our code will be easier to read and maintain.
July 1, 2018 | Swift, Protocols, Collections, iOS, macOS, tvOS, watchOS
The `Hashable` protocol in the Swift Standard Library allows us to use our own custom types as a key in a dictionary or as a member of a set. Conforming to `Hashable` where appropriate can make our code safer and improve performance. However, it's important to understand how `Hashable` and `Equatable` work together . . .
June 27, 2018 | Swift, Unit Testing, Scripting, iOS, macOS, tvOS, watchOS
In the last tutorial, we saw how to generate code coverage reports using the new `xccov` tool. Part of that process is using the `xcodebuild` command to build a project with code coverage enabled. We ran that command directly in Terminal, but we could also run `xcodebuild` in a Swift script. The problem is `xcodebuild` takes time, and . . .
June 21, 2018 | Swift, Unit Testing, Scripting, iOS, macOS, tvOS, watchOS
With the release of Xcode 9.3, Apple included a new command line tool called "xccov". It can be used to view code coverage reports as JSON, which can then be used to automate code coverage workflows. In this tutorial we'll see how to generate and view code coverage reports. We'll then write a Swift script to process the report.
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.