Taking the boilerplate out of your tests with Sourcery

Code generation has always been something of a controversial topic, with many engineers not liking the idea of a codebase that relies too much on this topic.
Yet, when used appropriately, this tool is a great help to minimize boilerplate code.

In many iOS projects, the testing targets are definitely places that tend to be cluttered with boilerplate and duplicated code.

Sourcery is a code-generation tool for Swift that, when applied appropriately, can dramatically reduce the amount of boilerplate.

In this talk I’m going to show you how it can be leveraged for quick win, such as making sure that your dependencies are correctly registered and injected.
But also to create building blocks for more involved tests scenarios, such as mocks that keep track of how many times methods get called, along with the provided arguments.
And, of course, if your app uses an architecture that relies on a set of well defined components (like base classes of ViewControllers, ViewModels, Providers, etc. with pre-defined methods), Sourcery can definitely be applied to generate a testing suite that will assert that those components behave as expected.


Session info:

Speaker: Vincent Pradeilles

Date: 15 March 2019

Time: 12:00 - 12:30

Relevant tags:
iOS Swift Testing 

See all speakers

See all videos