-
-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathintegration_test_runner.dart
executable file
·92 lines (79 loc) · 2.29 KB
/
integration_test_runner.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import 'dart:io';
void main(List<String> args) {
exitCode = 0;
bool isMacOS = false;
final testResults = [];
int errorCount = 0;
if (args.contains('--ios')) {
isMacOS = true;
final result = Process.runSync('which', ['applesimutils']);
if (result.exitCode != 0) {
print('''
------------------------------------------
WARNING: applesimutils is not installed
------------------------------------------
You can install it using homebrew:
brew tap wix/brew
brew install applesimutils
------------------------------------------''');
exit(1);
}
}
final testFilePaths = Directory('integration_test')
.listSync(recursive: true)
.whereType<File>()
.map((file) => file.path)
.toList();
for (final testFile in testFilePaths) {
if (isMacOS) {
final result = Process.runSync(
'applesimutils',
[
'--byName',
'iPhone 16 Pro Max',
'--bundle',
'org.freecodecamp.ios',
'--setPermissions',
'notifications=YES'
],
runInShell: true);
if (result.exitCode != 0) {
print('Test failed: $testFile');
print(result.stdout);
print(result.stderr);
exit(1);
}
}
print('Testing: $testFile');
final result = Process.runSync(
'flutter',
[
'drive',
'--no-pub',
'--driver=test_driver/integration_test.dart',
'--target=$testFile',
],
runInShell: true);
print(result.stdout);
if (result.exitCode != 0) {
print('Test failed: $testFile\n');
testResults.add('$testFile\n\n${result.stdout}');
errorCount++;
exitCode = 1;
}
}
if (errorCount > 0) {
final errorFile = File('screenshots/errors.txt');
errorFile.createSync(recursive: true);
errorFile.writeAsStringSync(testResults.join('\n\n'));
}
print('------------------------------------------');
print('Test summary:');
print('------------------------------------------');
print('Total: ${testFilePaths.length}');
print('Passed: ${testFilePaths.length - errorCount}');
print('Failed: $errorCount\n');
print('Failed tests output is in screenshots/errors.txt');
print('------------------------------------------');
exit(exitCode);
}