Created
August 17, 2021 12:06
-
-
Save SDS712/813551831fc7a45ac963d176f9e08353 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FCI_BUILD_DIR is a predefined environment variable pointing to the root of the Flutter project | |
cd $FCI_BUILD_DIR | |
# Write the environment variable in base64 into a JSON file | |
echo $GCLOUD_KEY_FILE | base64 --decode > ./gcloud_key_file.json | |
# Using the gcloud CLI (preinstalled on Codemagic) authenticate using the service account key | |
gcloud auth activate-service-account --key-file=gcloud_key_file.json | |
# Select YOUR Firebase project through which want to run the tests | |
gcloud --quiet config set project <OUR-PROJECT-ID-HERE> | |
#### ANDROID TESTING #### | |
# | |
# | |
# Go to the android folder which contains the "gradlew" script used | |
# for building Android apps from the terminal | |
pushd android | |
# Build an Android test APK (that's why we've created the MainActivityTest.java) | |
./gradlew app:assembleAndroidTest | |
# Build a debug APK, passing in the integration test file | |
./gradlew app:assembleDebug -Ptarget="$FCI_BUILD_DIR/integration_test/main.dart" | |
# Go back to the root of the project | |
popd | |
# Run the Flutter integration tests as if they were regular Android instrumentation tests | |
gcloud firebase test android run \ | |
--type instrumentation \ | |
--app build/app/outputs/apk/debug/app-debug.apk \ | |
--test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ | |
--use-orchestrator \ | |
--timeout 10m | |
#### IOS TESTING #### | |
# | |
# | |
output="../build/ios_integ" | |
product="build/ios_integ/Build/Products" | |
dev_target="14.4" | |
# Pass --simulator if building for the simulator. | |
flutter build ios integration_test/main.dart --release | |
pushd ios | |
# Create an IOS Testing build | |
xcodebuild -workspace Runner.xcworkspace -scheme Runner -config Flutter/Release.xcconfig -derivedDataPath $output -sdk iphoneos build-for-testing | |
popd | |
pushd $product | |
# Zip the contents on the build output to upload | |
zip -r "ios_tests.zip" "Release-iphoneos" "Runner_iphoneos$dev_target-arm64.xctestrun" | |
popd | |
# Run the Flutter integration tests as if they were regular IOS XCTests | |
gcloud firebase test ios run --test "build/ios_integ/ios_tests.zip" \ | |
--device model=iphone11pro,version=14.1,locale=en_US,orientation=portrait \ | |
--timeout 10m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment