From a9a4d62ca27577605f31a63edd22ac1fb0c7dfc0 Mon Sep 17 00:00:00 2001 From: oetzlinger <56891481+oetzlinger@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:24:42 +0200 Subject: [PATCH 1/2] BrowserStack Integration Fastlane --- src/fastlane/Fastfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/fastlane/Fastfile b/src/fastlane/Fastfile index bbc84f219..2ff7ffa52 100644 --- a/src/fastlane/Fastfile +++ b/src/fastlane/Fastfile @@ -37,6 +37,33 @@ platform :ios do output_name: $build_name ) end + + desc "Build UI tests for App Automate" + lane :ui_tests_app_automate do + clear_derived_data + + $output_dir = "fastlane/app_automate/" + $runner_path = "../" + $output_dir + $build_name + "-UITests.zip" + + gym( + scheme: $catty_schemes["debug"], + xcodebuild_formatter: "xcbeautify", + configuration: "Debug", + export_method: "development", + output_directory: $output_dir, + output_name: $build_name + ) + + scan( + scheme: $catty_schemes["debug"], + xcodebuild_formatter: "xcbeautify", + destination: "generic/platform=iOS", + disable_slide_to_type: false, + build_for_testing: true + ) + + sh("pushd " + lane_context[SharedValues::SCAN_DERIVED_DATA_PATH] + "/Build/Products/Debug-iphoneos && zip --symlinks -r $OLDPWD/" + $runner_path + " CattyUITests-Runner.app && popd") + end ########################################################################## # From 9cfcf974340ad6148f3756fdf120b10a4fedeb5b Mon Sep 17 00:00:00 2001 From: oetzlinger <56891481+oetzlinger@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:33:57 +0200 Subject: [PATCH 2/2] BrowserStack Integration Jenkinsfile --- Jenkinsfile | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index ebd2a3e97..b1c774f52 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,28 @@ pipeline { agent { label 'MAC' } + + tools {nodejs "NodeJS"} + + parameters { + separator(name: "BROWSERSTACK", sectionHeader: "BrowerStack configuration", + separatorStyle: "border-width: 0", + sectionHeaderStyle: """ + background-color: #ffff00; + text-align: center; + padding: 4px; + color: #000000; + font-size: 20px; + font-weight: normal; + font-family: 'Orienta', sans-serif; + letter-spacing: 1px; + font-style: italic; + """) + choice choices: ['IosDevices', 'iPhone 14 Pro-16', 'iPhone 14 Pro Max-16', 'iPhone 14 Plus-16', 'iPhone 14-16', 'iPhone 12 Pro Max-16', 'iPhone 12 Pro-16', 'iPhone 12 Mini-16', 'iPhone 11 Pro Max-16', 'iPhone XS-15', 'iPhone 13 Pro Max-15', 'iPhone 13 Pro-15', 'iPhone 13 Mini-15', 'iPhone 13-15', 'iPhone 11 Pro-15', 'iPhone 11-15', 'iPhone XS-14', 'iPhone 12 Pro Max-14', 'iPhone 12 Pro-14', 'iPhone 12 Mini-14', 'iPhone 12-14', 'iPhone 11 Pro Max-14', 'iPhone 11-14', 'iPhone XS-13', 'iPhone 11 Pro Max-13', 'iPhone 11 Pro-13', 'iPhone 11-13', 'iPhone XR-15', 'iPhone 8-15', 'iPhone 8-13', 'iPhone SE 2020-16', 'iPhone SE 2022-15', 'iPhone SE 2020-13', 'iPad Air 4-14', 'iPad 9th-15', 'iPad Pro 12.9 2022-16', 'iPad Pro 12.9 2020-16', 'iPad Pro 11 2022-16', 'iPad 10th-16', 'iPad Air 5-15', 'iPad Pro 12.9 2021-14', 'iPad Pro 12.9 2020-14', 'iPad Pro 11 2021-14', 'iPad Pro 12.9 2020-13', 'iPad 8th-16', 'iPad Pro 12.9 2018-15', 'iPad Mini 2021-15', 'iPad 8th-14', 'iPad Mini 2019-13', 'iPad Air 2019-13'], description: 'Available IOS Devices on BrowserStack', name: 'BROWSERSTACK_IOS_DEVICES' + booleanParam name: 'BROWSERSTACK_TESTING', defaultValue: false, description: 'When selected testing runs over BrowserStack' + booleanParam name: 'DEVICE_TESTING', defaultValue: true, description: 'When selected UI-testing runs locally' + choice choices: ['1', '2', '3', '4',' 5'], description: 'Number of Shards for running tests on BrowserStack. BrowserStack Dashboard', name: 'BROWSERSTACK_SHARDS' + } environment { PATH = "$HOME/.rbenv/shims:$PATH" @@ -31,6 +53,9 @@ pipeline { } } stage('Build') { + when { + expression { params.DEVICE_TESTING == true } + } steps { sh 'cd src && bundle exec fastlane ios build_catty' } @@ -42,6 +67,25 @@ pipeline { } } } + stage('BrowserStack testing') { + when { + expression { params.BROWSERSTACK_TESTING == true } + } + steps { + sh 'cd src && bundle exec fastlane ios ui_tests_app_automate' + withCredentials([usernamePassword(credentialsId: 'browserstack', passwordVariable: 'BROWSERSTACK_ACCESS_KEY', usernameVariable: 'BROWSERSTACK_USERNAME')]) { + script { + browserStack('src/fastlane/app_automate') + } + } + } + post { + always { + junit skipPublishingChecks: true, testResults: 'src/fastlane/report.xml' + // junitAndCoverage "$reports/jacoco/jacocoTestDebugUnitTestReport/jacoco.xml", 'unit', javaSrc + } + } + } stage('Test') { steps { sh 'cd src && bundle exec fastlane ios tests'