@@ -84,6 +84,85 @@ void main() {
84
84
]));
85
85
});
86
86
87
+ test ('only runs gcloud configuration once' , () async {
88
+ createFakePlugin ('plugin1' , packagesDir, extraFiles: < String > [
89
+ 'test/plugin_test.dart' ,
90
+ 'example/integration_test/foo_test.dart' ,
91
+ 'example/android/gradlew' ,
92
+ 'example/android/app/src/androidTest/MainActivityTest.java' ,
93
+ ]);
94
+ createFakePlugin ('plugin2' , packagesDir, extraFiles: < String > [
95
+ 'test/plugin_test.dart' ,
96
+ 'example/integration_test/bar_test.dart' ,
97
+ 'example/android/gradlew' ,
98
+ 'example/android/app/src/androidTest/MainActivityTest.java' ,
99
+ ]);
100
+
101
+ final List <String > output = await runCapturingPrint (runner, < String > [
102
+ 'firebase-test-lab' ,
103
+ '--device' ,
104
+ 'model=flame,version=29' ,
105
+ '--device' ,
106
+ 'model=seoul,version=26' ,
107
+ '--test-run-id' ,
108
+ 'testRunId' ,
109
+ '--build-id' ,
110
+ 'buildId' ,
111
+ ]);
112
+
113
+ expect (
114
+ output,
115
+ containsAllInOrder (< Matcher > [
116
+ contains ('Running for plugin1' ),
117
+ contains ('Firebase project configured.' ),
118
+ contains ('Testing example/integration_test/foo_test.dart...' ),
119
+ contains ('Running for plugin2' ),
120
+ contains ('Testing example/integration_test/bar_test.dart...' ),
121
+ ]),
122
+ );
123
+
124
+ expect (
125
+ processRunner.recordedCalls,
126
+ orderedEquals (< ProcessCall > [
127
+ ProcessCall (
128
+ 'gcloud' ,
129
+ 'auth activate-service-account --key-file=${Platform .environment ['HOME' ]}/gcloud-service-key.json'
130
+ .split (' ' ),
131
+ null ),
132
+ ProcessCall (
133
+ 'gcloud' , 'config set project flutter-infra' .split (' ' ), null ),
134
+ ProcessCall (
135
+ '/packages/plugin1/example/android/gradlew' ,
136
+ 'app:assembleAndroidTest -Pverbose=true' .split (' ' ),
137
+ '/packages/plugin1/example/android' ),
138
+ ProcessCall (
139
+ '/packages/plugin1/example/android/gradlew' ,
140
+ 'app:assembleDebug -Pverbose=true -Ptarget=/packages/plugin1/example/integration_test/foo_test.dart'
141
+ .split (' ' ),
142
+ '/packages/plugin1/example/android' ),
143
+ ProcessCall (
144
+ 'gcloud' ,
145
+ '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 --timeout 5m --results-bucket=gs://flutter_firebase_testlab --results-dir=plugins_android_test/plugin1/buildId/testRunId/0/ --device model=flame,version=29 --device model=seoul,version=26'
146
+ .split (' ' ),
147
+ '/packages/plugin1/example' ),
148
+ ProcessCall (
149
+ '/packages/plugin2/example/android/gradlew' ,
150
+ 'app:assembleAndroidTest -Pverbose=true' .split (' ' ),
151
+ '/packages/plugin2/example/android' ),
152
+ ProcessCall (
153
+ '/packages/plugin2/example/android/gradlew' ,
154
+ 'app:assembleDebug -Pverbose=true -Ptarget=/packages/plugin2/example/integration_test/bar_test.dart'
155
+ .split (' ' ),
156
+ '/packages/plugin2/example/android' ),
157
+ ProcessCall (
158
+ 'gcloud' ,
159
+ '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 --timeout 5m --results-bucket=gs://flutter_firebase_testlab --results-dir=plugins_android_test/plugin2/buildId/testRunId/0/ --device model=flame,version=29 --device model=seoul,version=26'
160
+ .split (' ' ),
161
+ '/packages/plugin2/example' ),
162
+ ]),
163
+ );
164
+ });
165
+
87
166
test ('runs integration tests' , () async {
88
167
createFakePlugin ('plugin' , packagesDir, extraFiles: < String > [
89
168
'test/plugin_test.dart' ,
@@ -203,12 +282,87 @@ void main() {
203
282
);
204
283
});
205
284
206
- test ('skips packages with no androidTest directory' , () async {
285
+ test ('fails for packages with no androidTest directory' , () async {
207
286
createFakePlugin ('plugin' , packagesDir, extraFiles: < String > [
208
287
'example/integration_test/foo_test.dart' ,
209
288
'example/android/gradlew' ,
210
289
]);
211
290
291
+ Error ? commandError;
292
+ final List <String > output = await runCapturingPrint (
293
+ runner,
294
+ < String > [
295
+ 'firebase-test-lab' ,
296
+ '--device' ,
297
+ 'model=flame,version=29' ,
298
+ '--device' ,
299
+ 'model=seoul,version=26' ,
300
+ '--test-run-id' ,
301
+ 'testRunId' ,
302
+ '--build-id' ,
303
+ 'buildId' ,
304
+ ],
305
+ errorHandler: (Error e) {
306
+ commandError = e;
307
+ },
308
+ );
309
+
310
+ expect (commandError, isA <ToolExit >());
311
+ expect (
312
+ output,
313
+ containsAllInOrder (< Matcher > [
314
+ contains ('Running for plugin' ),
315
+ contains ('No androidTest directory found.' ),
316
+ contains ('The following packages had errors:' ),
317
+ contains ('plugin:\n '
318
+ ' No tests ran (use --exclude if this is intentional).' ),
319
+ ]),
320
+ );
321
+ });
322
+
323
+ test ('fails for packages with no integration test files' , () async {
324
+ createFakePlugin ('plugin' , packagesDir, extraFiles: < String > [
325
+ 'example/android/gradlew' ,
326
+ 'example/android/app/src/androidTest/MainActivityTest.java' ,
327
+ ]);
328
+
329
+ Error ? commandError;
330
+ final List <String > output = await runCapturingPrint (
331
+ runner,
332
+ < String > [
333
+ 'firebase-test-lab' ,
334
+ '--device' ,
335
+ 'model=flame,version=29' ,
336
+ '--device' ,
337
+ 'model=seoul,version=26' ,
338
+ '--test-run-id' ,
339
+ 'testRunId' ,
340
+ '--build-id' ,
341
+ 'buildId' ,
342
+ ],
343
+ errorHandler: (Error e) {
344
+ commandError = e;
345
+ },
346
+ );
347
+
348
+ expect (commandError, isA <ToolExit >());
349
+ expect (
350
+ output,
351
+ containsAllInOrder (< Matcher > [
352
+ contains ('Running for plugin' ),
353
+ contains ('No integration tests were run' ),
354
+ contains ('The following packages had errors:' ),
355
+ contains ('plugin:\n '
356
+ ' No tests ran (use --exclude if this is intentional).' ),
357
+ ]),
358
+ );
359
+ });
360
+
361
+ test ('skips packages with no android directory' , () async {
362
+ createFakePackage ('package' , packagesDir, extraFiles: < String > [
363
+ 'example/integration_test/foo_test.dart' ,
364
+ ]);
365
+
212
366
final List <String > output = await runCapturingPrint (runner, < String > [
213
367
'firebase-test-lab' ,
214
368
'--device' ,
@@ -224,8 +378,8 @@ void main() {
224
378
expect (
225
379
output,
226
380
containsAllInOrder (< Matcher > [
227
- contains ('Running for plugin ' ),
228
- contains ('No example with androidTest directory ' ),
381
+ contains ('Running for package ' ),
382
+ contains ('package/ example does not support Android ' ),
229
383
]),
230
384
);
231
385
expect (output,
0 commit comments