---
title: "#291: Running Multiple UI Tests at Once with Bluepill 💊"
url: https://littlebitesofcocoa.com/291-running-multiple-ui-tests-at-once-with-bluepill
author: Jake Marsh
date: 2017-01-19
published: 2017-01-19
topics: ["Libraries","Testing"]
description: "We've covered UI Tests a fair amount over the years, but one thing has always stuck out: Running tests can be slow."
---

# #291: Running Multiple UI Tests at Once with Bluepill 💊

By Jake Marsh, January 19, 2017. HTML: https://littlebitesofcocoa.com/291-running-multiple-ui-tests-at-once-with-bluepill

We've covered UI Tests [a](https://littlebitesofcocoa.com/30-ui-testing) [fair](https://littlebitesofcocoa.com/129-more-ui-testing-tips) [amount](https://littlebitesofcocoa.com/124-more-on-ui-testing) over the years, but one thing has always stuck out: Running tests can be slow. <i>Very slow.</i>

Even if our individual tests themselves run quickly, the entire process is essentially "single threaded",  slow to start up and complete each pass, and is prone to strange errors.

Today we'll take a look at [Bluepill](https://github.com/linkedin/bluepill), a new tool from [LinkedIn](https://github.com/linkedin) that can help us with all of this by running multiple **iOS Simulators** in parallel, simultaneously. Let<a href="http://matrix.wikia.com/wiki/Redpill" style="text-decoration: none;">'</a>s dive in<a href="https://www.youtube.com/watch?v=zE7PKRjrid4" style="text-decoration: none;">.</a>

We'll start by cloning the repository, then running the build script that comes inside:

``` bash
./build.sh
```

This will build the command line tool. Once it's finsihed, we can copy the tool somewhere permanent:

``` bash
cp build/Build/Products/Debug/bp /usr/local/bin
```

Then rename it to something we can more easily identify:

``` bash
mv /usr/local/bin/bp /usr/local/bin/bluepill
```

(Note: `/usr/local/bin` is a common place to put command line tools on macOS thanks largely to the fact that [Homebrew](http://brew.sh/) puts things there, so it's likely already in our `$PATH`).

Now that we have [Bluepill](https://github.com/linkedin/bluepill) installed, let's try it out.

We can head back to our project and run something like:

``` bash
./bluepill -a ./Spaceships.app -s ./SpaceshipsUITests.xcscheme -o ./output/
```

This is great for quick runs, but ideally we'd be able to configure this sort of thing once and use it each time. Let's make a quick configuration file using `JSON`. We'll call it `bluepill-config.json`:

``` json
{
   "app": "./Spaceships.app",
   "scheme-path": "./SpaceshipsUITests.xcscheme",
   "output-dir": "./bluepill-logs/"
}
```

<p class='break'></p>

By default [Bluepill](https://github.com/linkedin/bluepill) will run `4` iOS Simulators simultaneously. Before we run our tests, let's turn that up a notch by adding one more option to our config file:

(This will cause our test to be run in up to **<i>12</i> iOS Simulators** at once. Very cool).

``` json
{
   "app": "./Spaceships.app",
   "scheme-path": "./SpaceshipsUITests.xcscheme",
   "output-dir": "./bluepill-logs/",
   "num-sims": 12
}
```

Finally, we can start our engines:

``` bash
./bluepill -c bluepill-config.json
```

<img src="https://media.littlebitesofcocoa.com/291-1.gif" style="max-width: 688px; border-radius: 4px; border: 4px solid black;" />

So awesome. 

Not only are we saving tons of time this way, but [Bluepill](https://github.com/linkedin/bluepill) also does other helpful things for us, such as automatically retrying when the Simulator hangs or crashes. Neat.

We've only scratched the surface of what's possible with [Bluepill](https://github.com/linkedin/bluepill). Be sure to check out the [README](https://github.com/linkedin/bluepill) for a full list of options and defaults. 

Learn more about [Bluepill](https://github.com/linkedin/bluepill) at [git.io/bluepill](https://git.io/bluepill).

<p></p>
