@@ -8,32 +8,33 @@ import 'dart:io';
88
99import 'package:flutter_test/flutter_test.dart' ;
1010import 'package:integration_test/src/constants.dart' ;
11+ import 'package:path/path.dart' as path;
1112
1213import 'utils.dart' ;
1314
14- // Assumes that the flutter command is in `$PATH`.
15- const String _flutterBin = ' flutter' ;
15+ final String _bat = Platform .isWindows ? '.bat' : '' ;
16+ final String _flutterBin = path. join ( Directory .current.parent.parent.parent.path, 'bin' , ' flutter$ _bat ' ) ;
1617const String _integrationResultsPrefix = 'IntegrationTestWidgetsFlutterBinding test results:' ;
1718
1819Future <void > main () async {
1920 test ('When multiple tests pass' , () async {
20- final Map <String , dynamic > results = await _runTest ('test/ reporter/ data/ pass_test_script.dart' );
21+ final Map <String , dynamic > results = await _runTest (path. join ( 'test' , ' reporter' , ' data' , ' pass_test_script.dart') );
2122
2223 expect (results, hasLength (2 ));
2324 expect (results, containsPair ('Passing test 1' , _isSuccess));
2425 expect (results, containsPair ('Passing test 2' , _isSuccess));
2526 });
2627
2728 test ('When multiple tests fail' , () async {
28- final Map <String , dynamic > results = await _runTest ('test/ reporter/ data/ fail_test_script.dart' );
29+ final Map <String , dynamic > results = await _runTest (path. join ( 'test' , ' reporter' , ' data' , ' fail_test_script.dart') );
2930
3031 expect (results, hasLength (2 ));
3132 expect (results, containsPair ('Failing test 1' , _isSerializedFailure));
3233 expect (results, containsPair ('Failing test 2' , _isSerializedFailure));
3334 });
3435
3536 test ('When one test passes, then another fails' , () async {
36- final Map <String , dynamic > results = await _runTest ('test/ reporter/ data/ pass_then_fail_test_script.dart' );
37+ final Map <String , dynamic > results = await _runTest (path. join ( 'test' , ' reporter' , ' data' , ' pass_then_fail_test_script.dart') );
3738
3839 expect (results, hasLength (2 ));
3940 expect (results, containsPair ('Passing test' , _isSuccess));
@@ -55,16 +56,16 @@ Future<Map<String, dynamic>> _runTest(String scriptPath) async {
5556 final String testResults = (await process.stdout
5657 .transform (utf8.decoder)
5758 .expand ((String text) => text.split ('\n ' ))
58- .map < dynamic > ((String line) {
59+ .map ((String line) {
5960 try {
60- return jsonDecode (line);
61+ return jsonDecode (line) as Map < String , dynamic > ;
6162 } on FormatException {
6263 // Only interested in test events which are JSON.
6364 }
6465 })
65- .where ((dynamic testEvent) =>
66+ .where ((Map < String , dynamic > testEvent) =>
6667 testEvent != null && testEvent['type' ] == 'print' )
67- .map ((dynamic printEvent) => printEvent['message' ] as String )
68+ .map ((Map < String , dynamic > printEvent) => printEvent['message' ] as String )
6869 .firstWhere ((String message) =>
6970 message.startsWith (_integrationResultsPrefix)))
7071 .replaceAll (_integrationResultsPrefix, '' );
0 commit comments