如何并行进行测试分片或运行以进行颤动

How to do test sharding or run in parallel for flutter

描述

我可以在测试包文档中看到 https://pub.dev/packages/test#sharding-tests 有一个参数可以对测试进行分片:

pub run test --total-shards 3 --shard-index 0 path/to/test.dart
pub run test --total-shards 3 --shard-index 1 path/to/test.dart
pub run test --total-shards 3 --shard-index 2 path/to/test.dart

当我在我的项目中尝试 运行 时,我得到:

Could not find package "test". Did you forget to add a dependency?
pub finished with exit code 65

但是当我尝试 运行 来自 flutter 的测试命令时,我可以看到:

$ flutter test  --total-shards 3 --shard-index 0  path/to/test.dart
Could not find an option named "total-shards".

Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.

当我 运行 flutter -h:

$ flutter test -h
Run Flutter unit tests for the current project.

Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commands executed.
                            If used with --help, shows hidden options.
-d, --device-id             Target device id or name (prefixes allowed).
    --version               Reports the version of this tool.
    --suppress-analytics    Suppress analytics reporting when this command runs.

Usage: flutter test [arguments]
-h, --help                            Print this usage information.
    --[no-]pub                        Whether to run "flutter pub get" before executing this command.
                                      (defaults to on)
    --[no-]null-assertions            Perform additional null assertions on the boundaries of migrated and unmigrated code. This
                                      setting is not currently supported on desktop devices.
    --[no-]track-widget-creation      Track widget creation locations. This enables features such as the widget inspector. This
                                      parameter is only functional in debug mode (i.e. when compiling JIT, not AOT).
                                      (defaults to on)
    --name=<regexp>                   A regular expression matching substrings of the names of tests to run.
    --plain-name=<substring>          A plain-text substring of the names of tests to run.
-t, --tags                            Run only tests associated with tags
-x, --exclude-tags                    Run only tests WITHOUT given tags
    --start-paused                    Start in a paused mode and wait for a debugger to connect.
                                      You must specify a single test file to run, explicitly.
                                      Instructions for connecting with a debugger are printed to the console once the test has started.
    --coverage                        Whether to collect coverage information.
    --merge-coverage                  Whether to merge coverage data with "coverage/lcov.base.info".
                                      Implies collecting coverage data. (Requires lcov)
    --coverage-path                   Where to store coverage information (if coverage is enabled).
                                      (defaults to "coverage/lcov.info")
    --update-goldens                  Whether matchesGoldenFile() calls within your test methods should update the golden files rather
                                      than test for an existing match.
-j, --concurrency=<jobs>              The number of concurrent test processes to run.
                                      (defaults to "10")
    --[no-]test-assets                Whether to build the assets bundle for testing.
                                      Consider using --no-test-assets if assets are not required.
                                      (defaults to on)
    --platform                        The platform to run the unit tests on. Defaults to "tester".
                                      [tester (default), chrome]
    --test-randomize-ordering-seed    The seed to randomize the execution order of test cases.
                                      Must be a 32bit unsigned integer or "random".
                                      If "random", pick a random seed to use.
                                      If not passed, do not randomize test case execution order.

我确实在测试文档 https://pub.dev/packages/test#shuffling-tests 中看到 --test-randomize-ordering-seed

在我看来,flutter 本身缺少这个功能,或者我没有在寻找我应该去的地方。

环境

flutter: 1.22.3

dev_dependencies:
  flutter_test:
    sdk: flutter

问题

我怎样才能 运行 我的并行测试?

目前无法实现,但我提出了这个 PR https://github.com/flutter/flutter/pull/76382,因此在部署之前它将可用。