iOS Automated Testing with Fastlane 🚀

iOS Automated Testing with Fastlane - Coletiv Blog

If you want to automatically test your iOS applications in your Continuous Integration (CI) service of choice, Fastlane is the tool for you.

You no longer need to browse the Internet in search of a script or create your own. It usually becomes extensive, less scalable and harder for someone else to quickly adjust it to new needs.

This article introduces Fastlane and explains how to use the Scan tool in order to achieve Automated Testing.

Due to the length of the article it is split into two parts that can be followed independent of each other:


Fastlane, currently maintained by Google, is a Continuous Delivery (CD) tool that comes with a wide set of base tools, each with its own purpose, being testing, deployment, incrementing project versions and many others. These will probably be more than enough for you, but you can also create or integrate plugins from the community.

In the old days, you had to create your own solution or fetch multiple scripts from other people in order to be able to automate the process of building and deploying your projects. This is why Fastlane is so great, you will find everything you need in one place, with a community to help you if necessary and a simple and embracing configuration that fits your needs.

If you are worried about pairing Fastlane with your CI service of choice, it already has tools to support the most popular ones: Travis CI, Bitrise, Circle CI and Jenkins.


Installing Xcode command line tools:

xcode-select --install

Installing Fastlane:

[sudo] gem install fastlane


brew cask install fastlane

NOTE: Make sure you have your terminal locale set to en_US.UTF-8. You can also add these to your .bash_profile file or to your terminal configuration.

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

NOTE: Make sure you have the correct Xcode selected

xcode-select -p

Setup Fastlane

fastlane init

Fastlane base setup options Fastlane base setup options

As you can see, Fastlane already comes with three base setups to facilitate the deployment automation, but this article only focus on automatically testing your applications, we will choose 4. Manual setup.

Fastlane will create a folder fastlane with an Appfile and a Fastfile which we can ignore for now.

For a more detailed tutorial or if you are having any problems following the guide so far, you can follow Fastlane setup guide.

Notes: Sample Project 📋

Notes is an iOS application that allows the user to add, remove and change notes. This project is used to illustrate how to do automated testing using Fastlane together with Travis CI.

The entire project is available on GitHub, for you to consult and use as you please.

Testing using Scan (from Fastlane)

Now we have to prepare the application for testing using Fastlane, more specifically, the Scan tool.

fastlane scan init

This command will create a Scanfile under your fastlane folder. This is the file you need to configure in order to properly test your application.

Simple configuration (for all the available configurations visit section Parameters):

# For more information about this configuration visit

# In general, you can use the options available
# fastlane scan --help

scheme "Notes"

devices ["iPhone 8"]

# Slack - uncomment the following lines for Slack Notifications
# slack_url "your_slack_url"
# slack_channel "your_slack_channel"

clean true

This simple configuration tests the scheme Notes, for the specified devices (iPhone 8), prints the results and sends a notification to Slack.

fastlane scan

Fastlane test results Fastlane test results

Fastlane Slack Notification Fastlane Slack Notification

NOTE: To get a slack_url you need to add the app Incoming WebHooks to your Slack and use the provided url, as simples as that!

Automated Testing using Travis CI

All you need to do now is add the scan command to your CI service script and you are good to go.

# Configuration
language: objective-c
osx_image: xcode9.2
xcode_sdk: iphonesimulator11.0
# Continuous Integration Script
#   fastlane scan - runs the application tests
- fastlane scan

In the future, you don’t need to modify the CI script to cope with testing related changes, you can do almost everything under the Scanfile.

Thank you for reading! 😊

I hope this guide helps you and your team saving some time with automated testing and remember to continuously check Fastlane advancements and updates. More and more tools will come that may expedite this enduring process of deployment!

Thank you so much for reading, it means a lot to us! Also don’t forget to follow Coletiv on Twitter and LinkedIn as we keep posting more and more interesting articles on multiple technologies.

In case you don’t know, Coletiv is a software development studio from Porto specialised in Elixir, iOS, and Android app development. But we do all kinds of stuff. We take care of UX/UI design, web development, and even security for you.

So, let’s craft something together?