How To Run iOS UI Tests In Parallel Using Bluepill Tool

How To Run iOS UI Tests In Parallel Using Bluepill Tool

Tudip

Tudip

01 June 2020

It’s very annoying when the test cases take a lot of time to complete the execution. Consider, you have 400+ test cases which take 5-6 hours to complete the test execution.

It will save a lot of time, if we can manage to reduce the test case execution time to 1-2 hours. We can achieve this by running the test cases in parallel using multiple simulators.

So, If you are implementing UI tests at large scale, you must need to achieve less time to complete the test run. You can improve it by using the Bluepill tool.

Introduction to Bluepill

Bluepill is a reliable iOS testing tool created by LinkedIn that runs iOS UI tests in parallel using multiple simulators.

Features 

  • Running tests in parallel by using multiple simulators.
  • Automatically packing tests into groups.
  • Generating a junit report after each test run.
  • Retrying when the Simulator hangs or crashes.

How to use Bluepill?

  1. Get the Bluepill binary
    You can get the build from the source : https://github.com/linkedin/bluepill/releases/Get binary from the (Homebrew) : $ brew install bluepill
  1. Run the tests
    Bluepill is easy to use, you just need to run the following command, and Bluepill will start running four simulators to run your tests in parallel. After the test run, it will generate a report in ./output

    ./bluepill -a ./MyApp.app -s ./MyAppTestScheme.xcscheme -o ./output/

    You can also have a configuration file as mentioned below:

    { 
    
    "app": "./MyAPP.app" 
    "scheme-path": "./MyAPPTestScheme.xcscheme" 
    "output-dir": "./build/" 
    }
    

    And run: ./bluepill -c config.json

Bluepill for fastlane support

You can also integrate the Bluepill into your project by using the fastlane plugin:

fastlane-plugin-bluepill

Fastlane Setup 

  • app : Your application path in derived data (/Products/Debug-iphonesimulator/YOUR_APP_NAME.app )
  • runner_app_path : UI test runner app path in derived data (/Products/Debug-iphonesimulator\YOUR_UITEST_SCHEME_NAME-Runner.app ).
    If there is any space in Scheme name then you have to amend it with backslash in your path.
  • scheme_path : (YOUR_PROJECT.xcodeproj/xcshareddata/xcschemes/YOUR_SCHEME.xcsche me )
  • output_dir : Bluepill reports will generate here
  • num_sims : Number of simulators to be launched.
  • runtime : The iOS version. “iOS 10.X”
  • device : eg: ‘iPhone 6s’
  • You can also use other options available for Bluepill from here: https://github.com/tbrand/fastlane-plugin-bluepill/blob/master/fastlane/Fastfile

Generate Derived Data for Bluepill 

You can generate derived date using fastlane scan:

scan(scheme: YOUR_SCHEME_NAME, 

build_for_testing: true, derived_data_path: "./bluepill", 

buildlog_path: "./bluepill/logs/" )

This will generate derived data inside the bluepill directory.

Configure the Fastfile 

lane: test do 

bluepill( 

app: 'path/to/YOUR_APP_NAME.app', 
scheme: 'path/to/YOUR_APP_NAME.xcscheme', 
output_dir: 'path/to/output_dir', 
device: 'iPhone 6s', number_of_simulators: 4, 
reuse_simulator: true ) 

end

Run the tests using fastlane: $ fastlane test

References 

 

search

Blog Categories

Request a quote