Repository: flutter
Issue: [integration_test] Enable sharding of integration test suites
Labels: a: tests,c: new feature,platform-android,framework,customer: crowd,c: proposal,f: integration_test,P3,team-android,triaged-android

<!-- 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
-->

## Use case
When running integration tests normally, the tests are executed sequentially on the connected device. 
This is fine if the integration test suite is small. But it does not scale well when the suite grows. 
This is an impediment for CI/CD pipelines containing integration tests because the integration tests will become the bottleneck. 
For example, I have a test suite containing 10 integration tests. Running those alone already takes about 12 minutes (only running the tests on the device, excluding the time it takes to build the tests). 

Sharding the integration test suite means to split the whole integration test suite into `n` shards which can be run in parallel on `n` devices to speed up running the whole integration test suite.

Firebase Test Lab provides an option `num-uniform-shards` to do this. [See the documentation here](https://cloud.google.com/sdk/gcloud/reference/beta/firebase/test/android/run#--num-uniform-shards) and note that this is only available on the beta channel of the gcloud sdk.

However, this option currently does not work with Flutter tests. When using the option, one shard contains all the tests and the other shards are empty. This causes the whole test suite to fail because shards should not be empty.
The flank team has [documented this quite nicely here](https://github.com/Flank/flank/blob/3a213579b0b8ed7ca018314f0619146408292b35/docs/flutter_status.md#--num-uniform-shards) with an [example project containing integration tests](https://github.com/Flank/flank/tree/master/test_projects/flutter/flutter_example).


<details>
  <summary>Excerpt from flank's documentation</summary>

## --num-uniform-shards

Test:

```shell
gcloud alpha firebase test android run \
  --project flank-open-source \
  --type instrumentation \
  --app build/app/outputs/apk/debug/app-debug.apk \
  --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
  --num-uniform-shards=3 \
  --timeout 5m
```

Result:

```shell
┌─────────┬────────────────────────┬───────────────────────────────┐
│ OUTCOME │    TEST_AXIS_VALUE     │          TEST_DETAILS         │
├─────────┼────────────────────────┼───────────────────────────────┤
│ Failed  │ walleye-27-en-portrait │ 1 test cases failed, 5 passed │
└─────────┴────────────────────────┴───────────────────────────────┘
```

#### Expected behaviour

The Flutter example app contains 6 test methods, so according to doc, the gcloud should create 3 shards, each shard should contain 2 methods.

#### Investigation results

* One shard contains all test's
* Two other shards are being empty.

#### Conclusions

The result is different from expected behaviour.


</details>

<!--
     Please tell us the problem you are running into that led to you wanting
     a new feature.

     Is your feature request related to a problem? Please give a clear and
     concise description of what the problem is.

     Describe the alternative solutions you've considered. Is there a package
     on pub.dev/flutter that already solves this?
-->

## Proposal

<!--
     Briefly but precisely describe what you would like Flutter to be able to do.

     Consider attaching something showing what you are imagining:
      * images
      * videos
      * code samples

     Does this have to be provided by Flutter directly, or can it be provided
     by a package on pub.dev/flutter? If so, maybe consider implementing and
     publishing such a package rather than filing a bug.
-->

I would like to be able to shard an integration test suite so it can be run faster by executing the shards in parallel on multiple devices. 

More specifically, I would like to be able to use the `--num-uniform-shards` option of Firebase Test Lab.