Add details to the iOS part integration_test (#74428)

This commit is contained in:
Romain Rastel 2021-01-22 02:26:07 +01:00 committed by GitHub
parent 550a85dabd
commit 0a668b9804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,8 +182,10 @@ devices you want to test on. See
Open `ios/Runner.xcworkspace` in Xcode. Create a test target if you
do not already have one via `File > New > Target...` and select `Unit Testing Bundle`.
Change the `Product Name` to `RunnerTests`. Make sure `Target to be Tested` is set to `Runner`.
Change the `Product Name` to `RunnerTests`. Make sure `Target to be Tested` is set to `Runner` and language is set to `Objective-C`.
Select `Finish`.
Under **Runner** > **Info** > **Configurations** section, make sure, that `Runner` and `RunnerTests` have the same value under each configuration.
Make sure that the **iOS Deployment Target** of `RunnerTests` within the **Build Settings** section is the same as `Runner`.
Add the new test target to `ios/Podfile` by embedding in the existing `Runner` target.
@ -217,3 +219,33 @@ To build `integration_test/foo_test.dart` from the command line, run:
# Pass --simulator if building for the simulator.
flutter build ios integration_test/foo_test.dart
```
To deploy it to Firebase Test Lab you can follow these steps:
Execute this script at the root of your Flutter app:
```sh
output="../build/ios_integ"
product="$output/Build/Products"
dev_target="14.3"
# Pass --simulator if building for the simulator.
flutter build ios integration_test/foo_test.dart -release
pushd ios
xcodebuild -workspace Runner.xcworkspace -scheme Runner -config Flutter/Release.xcconfig -derivedDataPath $output -sdk iphoneos build-for-testing
zip -r "$output/ios_tests.zip" "$product/Release-iphoneos" "$product/Runner_iphoneos$dev_target-arm64.xctestrun"
popd
```
You can verify locally that your tests are succesful by running the following command:
```sh
xcodebuild test-without-building -xctestrun "build/ios_integ/Build/Products/Runner_iphoneos14.3-arm64.xctestrun" -destination id=<YOUR_DEVICE_ID>
```
Once everything is ok, you can upload the resulting zip to Firebase Test Lab (change the model with your values):
```sh
gcloud firebase test ios run --test "build/ios_integ/ios_tests.zip" --device model=iphone11pro,version=14.1,locale=fr_FR,orientation=portrait
```