gpt4 book ai didi

flutter - 如何对 flutter 进行测试分片或并行运行

转载 作者:行者123 更新时间:2023-12-04 15:13:07 24 4
gpt4 key购买 nike

描述
我可以在测试包文档中看到 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.
我确实看到了 --test-randomize-ordering-seed这也在测试文档中 https://pub.dev/packages/test#shuffling-tests .
在我看来,flutter 本身缺少此功能,或者我可能没有找到我应该找的地方。
环境
flutter: 1.22.3

dev_dependencies:
flutter_test:
sdk: flutter

如何并行运行我的测试?

最佳答案

目前不可能,但我做了这个 PR https://github.com/flutter/flutter/pull/76382 ,因此在部署之前它将是可用的。

关于flutter - 如何对 flutter 进行测试分片或并行运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64846907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com