iOS Mobile Testing: Parallel Execution with Fastlane

Getting started

Fastlane for iOS

Executing tests via command line

  • Navigate to created fastlane directory cd fastlane/
  • Open Fastfile in text editor
  • Set scheme according to your project scheme name
  • Specify test device
lane :uiTest do
scan(
scheme: 'ExampleFastLaneiOSUITests', # Project scheme name
clean: true, # Clean project folder before test execution
device: 'iPhone 8 plus' # Simulator for testing
)
end
  • Execute fastlane uiTest
  • Wait for tests to be executed
Test execution in Simulator

Improving Test Reports

desc "Generate test reports"
def generate_report
puts "Generating Test Report ..."
sh 'xchtmlreport -r test_output/ExampleFastLaneiOSUITests.xcresult -i'
puts "Test Report Succesfully generated"
end

Running tests in parallel on multiple devices

TEST_SIMULATORS = ['iPhone 8','iPhone SE (3rd generation)','iPad mini (6th generation)']
lane :uiTest do
scan(
scheme: 'ExampleFastLaneiOSUITests', # Project scheme name
clean: true, # clean project folder before test execution
devices: TEST_SIMULATORS
)
end
Parallel Test Execution on Simulators
  • Navigate to the Display & Brightness section
  • Set Auto-Lock to Never
  • Navigate to the Do Not Disturb section
  • Enable Do Not Disturb mode
  • Set Silence to always
REAL_DEVICES = [
'platform=iOS,id=2a31ef65jc84c16er657af3f29901c20917g37',
'platform=iOS,id=78a91ef5bf2036fa49ec3df1af356jh5676390'
]private_lane :real_device_test do
scan(
scheme: 'ExampleFastLaneiOSUITests', # Project scheme name
clean: true, # Clean project folder before test execution
destination: REAL_DEVICES, # Devices for testing
result_bundle: "TestResults" # To generate test reports
)
generate_report
end
  • fail_build: false # Otherwise following steps won’t be executed
  • disable_concurrent_testing: true # to stop parallel execution and enable sequential testing order
  • testplan: ‘’ #define the test plan you wish to execute (eg: smoke, regression, etc…)
Test Report example

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dilshan Fernando

Dilshan Fernando

Quality Engineering | Test Automation Engineer | AWS Certified Solutions Architect | Problem Solver