Skip to content

Instantly share code, notes, and snippets.

View wf-adamhei's full-sized avatar

Adam Heimendinger wf-adamhei

View GitHub Profile
desc “Run UI Tests on iPhone 11 Pro”
lane :ui_tests
tests_to_run = options[:only_testing]
clear_derived_data(derived_data_path: derived_data_path)
sh(“xcrun simctl shutdown booted”)
sh(“xcrun simctl erase all”)
sh(“xcrun instruments -w ‘iPhone 11 Pro (13.3) [‘ -t Blank”)
scan(workspace: “Wealthfront.xcworkspace”,
scheme: “WealthfrontUITests”,
output_style: “basic”,
def getAllUITestClassNames() {
def allSwiftFiles = sh(
script: “find WealthfrontUITests -name ‘*.swift’”,
returnStdout: true
).trim().split(‘\n’) as String[]
def directory = pwd()
def allClassNames = []
allSwiftFiles.each {
def file = readFile “${directory}/${it}”
def matcher = (file =~ /(?<=class ).*?(?=:)/)
def partitionTestClassNames(classNames, buckets) {
def subArrays = []
def bucketSize = classNames.size() / buckets
for (int i = 0; i < buckets; i++) {
def start = i * bucketSize
def end = i == buckets - 1 ? classNames.size() : start + bucketSize
subArrays += [classNames[start..<end]]
}
return subArrays
}
partitioned_test_cases = []
pipeline {
environment {
TARGET_PARALLEL_AGENTS = 3
}
stages {
stage(“Partition UI tests”) {
steps {
partitioned_test_cases = []
pipeline {
agent { label ‘iOS’ }
environment {
TARGET_PARALLEL_AGENTS = 3
}
stages {
USERNAME=`id -un`
PASSWORD=`security find-generic-password -ws $WF_CI_KEYCHAIN_ITEM_NAME`
# Map USER + PASSWORD to test account credentials
# ...
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
private let WFAccessGroupKey: String = "WFAccessGroup"
private let WFCredentialHelperServiceKey: String = "WFCredentialHelperServiceName"
private let AccessPropertiesPlistName: String = "KeychainAccessGroupBridge-Dev"
private let TestAccountUsernameKey = "TestAccountUsernameKey"
private let TestAccountPasswordKey = "TestAccountUsernameKey"
# Find credentials in keychain
# ...
# Create test account credentials ($USER + $PASS)
# ...
# Boot target simulator if not already booted
# ...
xcrun simctl get_app_container $TARGET_DEVICE_IDENTIFIER com.Wealthfront.CredentialHelper 2> /dev/null
if [[ $? -e 0 ]]; then