Automate iOS App testing with Continuous Integration service

ydcat
2 min readMay 29, 2022

When tests coverage large portion of code base, we could make the automation a bit further by setup a service to run all the tests. There are many online vendors: github actions, circle CI, travis CI. If your code host in github, github action have better integration and less setup steps.

How CI works

CI service work as a server. It’s a computer that runs on demand.

When develop in local machine, you build and run all the tests. The CI server does the something. It has its own operating system. It build the App and run tests follow the config you specified. The CI runs every time you push to a branch or making pull requests. Some even could run regularly.

Build CI config easily

To make the CI more elegant, there are many local tools for automation like Fastlane and Make. For mobile App, Fastlane helps you along the way of development.

The strategy is in the local development, using tools like Fastlane to manage all the building and testing details. Then in the CI server, install the dependencies first, run Fastlane as in the local.

In this way, you could make the CI steps platform independent and switch services you like.

How to set CI on Circle CI

You could choose any online service or setup one by yourself. Considering the cost and keep the repository private, I use Circle CI for iOS App testing.

Before using Circle CI you need to connect your git account (such as github, gitlab or bitbucket). Then add a config.yml in .circleci folder. For build and test the App, considering following configuration.

version: 2.1
jobs:
build-and-test:
macos:
xcode: 13.3.0
environment:
FL_OUTPUT_DIR: output
FASTLANE_LANE: test
steps:
- checkout
- run: bundle install
- run:
name: Fastlane
command: bundle exec fastlane $FASTLANE_LANE
- store_test_results:
path: output/scan


workflows:
Test:
jobs:
- build-and-test

If you use service like github action, add steps to install Fastlane. Other parts are pretty the same as the configuration above.

Final

This article shares the basics for setup a CI service. It’s just a beginner step of the continuous integrate journey. In fact, almost any step you run local by commands could be automated in the CI. Hope to know more about how you using CI.

--

--

ydcat

Indie developer. Creator of iOS App — Inspire Board. Coding in Python, Swift and JavaScript. Share thoughts and innovation. Attempting to learn and write more.