Skip to content

Commit fa1a865

Browse files
ci: configure GitHub Actions to use integration_test package (#8910)
* Add `integration_test.dart` * Add dummy `e2e_test.dart` file * Add `integration_test` package * Run integration tests for every pull request * Use `IntegrationTestWidgetsFlutterBinding.ensureInitialized();` * Format & use `flutter test` * Use multidex * Add new line for `FlutterMultiDexApplication.java` * Format to pass CI * Add comment for `flutter drive` command * Use `flutter test` command for macos test * Format test command for android * Use one line comment * Re-trigger CI * Re-trigger CI * Bump `minSdkVersion` to 21 for tests app
1 parent 2854cbc commit fa1a865

File tree

6 files changed

+44
-9
lines changed

6 files changed

+44
-9
lines changed

.github/workflows/e2e_tests.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
working-directory: tests
7171
script: |
7272
sleep 15
73-
flutter drive --target=./test_driver/driver_e2e.dart --dart-define=CI=true
73+
flutter test integration_test/e2e_test.dart --dart-define=CI=true
7474
7575
ios:
7676
runs-on: macos-latest
@@ -118,7 +118,7 @@ jobs:
118118
export CCACHE_DEPEND=true
119119
export CCACHE_INODECACHE=true
120120
ccache -s
121-
flutter build ios --no-codesign --simulator --debug --target=./test_driver/driver_e2e.dart --dart-define=CI=true
121+
flutter build ios --no-codesign --simulator --debug --target=integration_test/e2e_test.dart --dart-define=CI=true
122122
ccache -s
123123
- name: Start Firebase Emulator
124124
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
@@ -133,7 +133,7 @@ jobs:
133133
sleep 15
134134
# Uncomment following line to have simulator logs printed out for debugging purposes.
135135
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
136-
flutter drive -d "$SIMULATOR" --target=./test_driver/driver_e2e.dart --dart-define=CI=true
136+
flutter test integration_test/e2e_test.dart -d "$SIMULATOR" --dart-define=CI=true
137137
FLUTTER_DRIVE_EXIT_CODE=$?
138138
xcrun simctl shutdown "$SIMULATOR"
139139
exit $FLUTTER_DRIVE_EXIT_CODE
@@ -190,14 +190,17 @@ jobs:
190190
export CCACHE_DEPEND=true
191191
export CCACHE_INODECACHE=true
192192
ccache -s
193-
flutter build macos --debug --target=./test_driver/driver_e2e.dart --device-id=macos --dart-define=CI=true
193+
flutter build macos --debug --target=integration_test/e2e_test.dart --device-id=macos --dart-define=CI=true
194194
ccache -s
195195
- name: Start Firebase Emulator
196196
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
197197
- name: "E2E Tests"
198198
working-directory: tests
199199
run: |
200-
flutter drive -d macos --target=./test_driver/driver_e2e.dart --dart-define=CI=true
200+
flutter test \
201+
integration_test/e2e_test.dart \
202+
-d macos \
203+
--dart-define=CI=true
201204
202205
web:
203206
runs-on: ubuntu-latest
@@ -229,6 +232,14 @@ jobs:
229232
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
230233
- name: "E2E Tests"
231234
working-directory: tests
235+
# Web devices are not supported for the `flutter test` command yet. As a
236+
# workaround we can use the `flutter drive` command. Tracking issue:
237+
# https://github.com/flutter/flutter/issues/66264
232238
run: |
233239
chromedriver --port=4444 &
234-
flutter drive --verbose-system-logs --device-id=web-server --target=./test_driver/driver_e2e.dart --dart-define=CI=true
240+
flutter drive \
241+
--verbose-system-logs \
242+
-d web-server \
243+
--driver=test_driver/integration_test.dart \
244+
--target=integration_test/e2e_test.dart \
245+
--dart-define=CI=true

tests/android/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ android {
4747
defaultConfig {
4848
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4949
applicationId "io.flutter.plugins.firebase.tests"
50-
minSdkVersion 19
50+
minSdkVersion 21
5151
targetSdkVersion flutter.targetSdkVersion
5252
versionCode flutterVersionCode.toInteger()
5353
versionName flutterVersionName
54+
multiDexEnabled true
5455
}
5556

5657
buildTypes {
@@ -67,5 +68,6 @@ flutter {
6768
}
6869

6970
dependencies {
71+
implementation 'com.android.support:multidex:1.0.3'
7072
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7173
}

tests/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
// Generated file.
2+
//
23
// If you wish to remove Flutter's multidex support, delete this entire file.
4+
//
5+
// Modifications to this file should be done in a copy under a different name
6+
// as this file may be regenerated.
37

48
package io.flutter.app;
59

10+
import android.app.Application;
611
import android.content.Context;
712
import androidx.annotation.CallSuper;
813
import androidx.multidex.MultiDex;
914

10-
/** Extension of {@link io.flutter.app.FlutterApplication}, adding multidex support. */
11-
public class FlutterMultiDexApplication extends FlutterApplication {
15+
/** Extension of {@link android.app.Application}, adding multidex support. */
16+
public class FlutterMultiDexApplication extends Application {
1217
@Override
1318
@CallSuper
1419
protected void attachBaseContext(Context base) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:integration_test/integration_test.dart';
3+
4+
void main() {
5+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
6+
7+
group('FlutterFire', () {
8+
test('dummy test', () {
9+
expect(true, true);
10+
});
11+
});
12+
}

tests/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ dev_dependencies:
202202
sdk: flutter
203203
flutter_test:
204204
sdk: flutter
205+
integration_test:
206+
sdk: flutter
205207

206208
flutter:
207209
uses-material-design: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'package:integration_test/integration_test_driver.dart';
2+
3+
Future<void> main() => integrationDriver();

0 commit comments

Comments
 (0)