Advanced Unit Testing Workshop

Purpose: This workshop is designed for iOS engineers who want to build their testing skills. There’s a lot of app testing done at workplaces with manual QA, FCTs etc. The concepts learned here can greatly help increase your confidence while shipping and ensuring that bugs don’t resurface. It’ll also save up on a lot of effort by automating all of this work away, so you can focus on building great apps.

For this workshop, we’ll create a very simple game app and figure out how to write tests for it. We’ll cover how to test various parts of the game: mechanics, talking to a backend, caching etc.

Session 1: Writing testable code

10:00 AM - 10:30 AM

In this session, we’ll explore what it means to write testable code, and what’re the benefits we gain - things like decoupling interfaces, prototyping etc. We’ll also go over some definitions(TDD, the end to end tests etc) as a refresher for beginner devs.

Session 2: Mocking

10:30 AM - 11:15 AM

We’ll cover Mocking various parts of your app. We’ll explore which parts of your app are more “mockable” from a maintenance perspective (with an example of a networking client). We’ll also explore the idea of building a “Mock only” target for your app (which is useful for demos to product owners when you want to prevent flakiness)

Coffee Break: 11:15 AM - 11:30 AM

Session 3: Tooling

11:30 AM - 12:30 PM

We’re writing all of these tests but we’re running into one problem: we wish to talk to production backends but we don’t want to save sensitive data in version control! We’ll explore some of the code generation toolings in the Swift community and figure out a way to integrate code generation into our testing setup

Session 4: Fuzzing

12:30 PM - 01:30 PM

Often hard-coded, “one scenario” tests don’t cover the range of scenarios that can happen in our app. We’ll introduce another form of testing: Fuzz testing to introduce randomness and try to “break” our app as much as possible. We’ll also explore setups on correctly logging failure scenarios when our tests fail on CI

Lunch Break: 01:30 PM - 02:30 PM

Session 5: Functional/Mock free testing

02:30 PM - 03:30 PM

We ’ll create a very simple network client that is “substrate independent” and can be adapted to work with any network library of your choice(Alamofire, URLSession, anything). We’ll add extensions to demonstrate the ability to reuse this in multiple apps.

Coffee Break: 03:30 PM - 03:45 PM

Session 6: Testing Side Effects

03:45 PM - 04:30 PM

In some cases, we’re only concerned with the behavior of a system rather than any outputs (cache systems, databases are a great example). We’ll explore how to test these behaviors.

Session 7: Time based tests

04:30 PM - 05:00 PM

Now that we’re testing side effects, we notice that the order and timing of side-effects are sometimes important to the functionality in our apps. We’ll figure out how to test time-based behaviors.

Optional: we’ll take a detour into RxTest to see why it might be a great abstraction over tests.

Session 8: Snapshot testing (Backup)

05:00 PM - 06:00 PM

In this session I’ll explore an alternate version of snapshot testing that uses recursive text descriptions rather than image data, using Pointfree’s delightful testing library: https://github.com/pointfreeco/swift-snapshot-testing


Workshop Instructor

Robin Malhotra is an iOS engineer at GO-JEK, Indonesia’s first unicorn company. His love affair with computers started with his dad’s hand-me-down IBM PC. He’s a huge swift fan (both & Taylor) who spends his free time playing basketball (Go Dubs!) and working on open source. When he’s not programming or wasting time on Reddit, he usually plays NBA 2K, Overwatch or Mass Effect. He’s previously spoken at try! Swift Bangalore, and also speaks regularly at the Swift India meetups.

Twitter: https://twitter.com/codeofrobin


Workshop Location

GO-JEK Bangalore. ( 27th July morning to evening )