Repository: flutter
Issue: [integration_test] IntegrationTestWidgetsFlutterBinding reportData won't allow for "Array of Objects" JSON because it is Map
Labels: a: tests,f: integration_test,has reproducible steps,P3,found in release: 3.3,found in release: 3.7,team-framework,triaged-framework

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Add this test to the example test in the master branch of the plugins repo:

```dart
testWidgets('failure 2', (WidgetTester tester) async {
    (tester.binding as IntegrationTestWidgetsFlutterBinding).reportData = {'1': 1};
    expect(1 + 1, 2);
  });
```
and integration_test.dart:
```dart
import 'package:integration_test/integration_test_driver.dart' as integration_test_driver;

Future<void> main() {
  integration_test_driver.testOutputsDirectory = 'integration_test/gherkin/reports';

  return integration_test_driver.integrationDriver();
}
```
2. Run tests
3. Change 

```dart
(tester.binding as IntegrationTestWidgetsFlutterBinding).reportData = {'1': 1};
``` 
to 

```dart
(tester.binding as IntegrationTestWidgetsFlutterBinding).reportData = [{'1': 1}];
```

4. Run tests again. 

**Expected results:** On step 2 there is File created in folder integration_test/gherkin/reports with JSON parsed contents of reportData. On step 4 - same result.

**Actual results:** On step 2 everything is fine, but on step 4 tests will fail - not surprisingly, because static analysis showed us that reportData is typed as Map<String, dynamic>, while JSON allows for Arrays too.

Why it is important: cucumber JSON format is actually an Array of Objects, so you can't use testing framework to generate correct JSON.
By the way, I have a fix for this in this commit: https://github.com/vrnvorona/plugins/commit/efa7dfa1877c2dec36d12df6becc1a4c589696d3 

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
Using device iPhone 8 Plus.
Starting application: test_driver/failure.dart
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to the App Store.
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         4.0s
Xcode build done.                                           16.8s
flutter: Observatory listening on http://127.0.0.1:65352/PO6CDn3uFuo=/
VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:65352/PO6CDn3uFuo=/
VMServiceFlutterDriver: Isolate found with number: 3927553815740579
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
flutter: find_me
flutter: tearing_down_real
flutter: 00:00 +0: failure 2
flutter: ---<outerCallbackCall>---
flutter: ---<outerCallbackCall>---
VMServiceFlutterDriver: Connected to Flutter application.
---<serialize_request_data>---
flutter: ---<outerCallbackCall>---
flutter: ---<testCompletionHandler>---
flutter: ---<testCompletionHandler>---
flutter: 00:00 +1: (tearDownAll)
flutter: invoked allTestsFinished
flutter: Warning: integration_test test plugin was not detected.
flutter: ---<outerCallbackCall>---
flutter: 00:00 +2: All tests passed!
----<fromJson>----
message: {"result":"true","failureDetails":[],"data":{"1":1}}
----<fromJson>----
All tests passed.
Stopping application instance.
➜  example git:(json_type_fix) ✗ flutter drive --driver=test_driver/integration_test_driver.dart --target=test_driver/failure.dart
Using device iPhone 8 Plus.
Starting application: test_driver/failure.dart
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to the App Store.
Running Xcode build...                                                  
Xcode build done.                                           12.7s
Failed to build iOS app
Error output from Xcode build:
↳
    2021-01-20 18:09:48.170 xcodebuild[16146:17122929]  DVTProvisioningProfileManager: Failed to load profile "/Users/voronin/Library/MobileDevice/Provisioning Profiles/match_Development_rusbiiosstage.mobileprovision" (Error
    Domain=DVTProvisioningProfileProviderErrorDomain Code=1 "Failed to load profile." UserInfo={NSLocalizedDescription=Failed to load profile., NSLocalizedRecoverySuggestion=Profile is missing the required UUID property.})
    ** BUILD FAILED **


Xcode's output:
↳
    test_driver/failure.dart:25:75: Error: A value of type 'List<Map<String, int>>' can't be assigned to a variable of type 'Map<String, dynamic>'.
     - 'List' is from 'dart:core'.
     - 'Map' is from 'dart:core'.
        (tester.binding as IntegrationTestWidgetsFlutterBinding).reportData = [{'1': 1}];
                                                                              ^

    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'integration_test' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'Runner' from project 'Runner')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'Flutter' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'Pods-Runner' from project 'Pods')

Could not build the application for the simulator.
Application failed to start. Will not run test. Quitting.

```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-RU)
    • Flutter version 1.22.5 at /usr/local/flutter
    • Framework revision 7891006299 (6 weeks ago), 2020-12-10 11:54:40 -0800
    • Engine revision ae90085a84
    • Dart version 2.10.4

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/voronin/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/voronin/Library/Android/sdk
    • Java binary at: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode-12.1.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.10.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2020.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 46.0.3
    • Dart plugin version 201.7223.43

[!] VS Code (version 1.52.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • iPhone 8 Plus (mobile) • AD6DDB6C-44AB-4655-81C4-AAC5C241F4A2 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-7 (simulator)

! Doctor found issues in 2 categories.

```

</details>