Advanced Unit Testing Workshop

Advanced Unit Testing

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 learnt 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 components for a very simple app(an API Client, master-detail views, data caches) 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: Mock Targets and what do you mock?

Estimated time: 09:30 AM - 10: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)

Session 2: Tooling

Estimated time: 10:15 AM - 10:45 AM

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 tooling in the Swift community and figure out a way to integrate code generation into our testing setup. We’ll also look at ways to decouple parts of your app quickly by taking advantage of project generation

Session 3: Fuzzing

Estimated time: 10:45 AM - 11:15 AM

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

Break

Estimated time: 11:15 AM - 11:30 AM

Session 4: Functional/Mock free testing

Estimated time: 11:30 AM - 12: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.

Session 5: Snapshot testing (Backup)

Estimated time: 12:30 PM - 01: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

Session 6: Q & A

Estimated time: 01:00 PM - 01:30 PM


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 Saturday July 09:00 AM to 01:30 PM )