This project demonstrates the use of percy.io on apple sample code application UIKitCatalog.
Steps for adding percy tests:
-
download and add XCTestCase+percySnapshot.swift to the UI Testing target. You can get the code from: percy-ios-uitest-helpers
-
write/record UI Test and add percyScreenshot calls (we recommend starting with smaller number of screenshots and extending later)
-
add Gemfile and percy.rb from percy-ios Gemfile:
source 'https://rubygems.org' gem 'percy-ios', github: 'mfazekas/percy-ios'
percy.rb
require 'percy/ios' raise 'please pass derived-data as first argument' if ARGV[0].nil? percy = Percy::IOS.new percy.derived_data_dir=ARGV[0] percy.upload_screenshots
-
run
bundle install
(if you don't have bundler installer you need to executegem install bundler
before) -
register to percy.io and make note of your write only api key.
-
run 'xcodebuild' and percy locally make sure you specify derevedDataPath to xcodebuild. You can run your tests on multiple devices.
rm -rf ./derived-data ; xcodebuild test -scheme UIKitCatalog -onlyTesting:UIKitCatalogPercyTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 5,OS=10.1' -destination 'platform=iOS Simulator,name=iPad Air,OS=10.1' -derivedDataPath ./derived-data PERCY_TOKEN=*** PERCY_PROJECT=mfazekas/UIKitCatalog-percy-sample PERCY_BRANCH=master bundle exec ruby ./percy.rb ./derived-data
-
Add travis.yml file and configure PERCY_TOKEN and PERCY_PROJECT in travis, and make sure your shceme is set to shared and autocreate:
language: objective-c os: osx osx_image: xcode8 script: - xcodebuild test -scheme UIKitCatalog -only-testing:UIKitCatalogPercyTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 5,OS=10.0' -destination 'platform=iOS Simulator,name=iPad Air,OS=10.0' -derivedDataPath ./derived-data - bundle exec ruby ./percy.rb ./derived-data
The is based on UIKitCatalog sample code from Apple. See LICENSE_original and README_original for information on the sample code itself.