我怎样使用sdk中的flutter_test和软件包测试?什么版本的测试使用test_API 0.4.3?

ogsagwnx  于 2022-12-30  发布在  Flutter
关注(0)|答案(3)|浏览(160)

我正在尝试为我的flutter应用运行一些基本的单元测试,但是当我运行pub get时,我在包含test之后得到了以下错误:1.20.0在我的发布规范中:

dev_dependencies:
  dependency_validator: ^3.1.0 # run flutter pub run dependency_validator
  #integration_test:
  #  sdk: flutter
  flutter_test:
    sdk: flutter
  test: ^1.20.0

所以当我运行f pub get时,我看到:

Because test >=1.20.0 depends on test_api 0.4.9 and every version of flutter_test from sdk depends on test_api 0.4.3, test >=1.20.0 is incompatible with flutter_test from sdk.
    So, because myapp depends on both flutter_test from sdk and test ^1.20.0, version solving failed.
    pub get failed (1; So, because myapp depends on both flutter_test from sdk and test ^1.20.0, version solving failed.)```

What version of test uses test_api  0.4.3?
ukdjmx9f

ukdjmx9f1#

我可以只使用导入'package:flutter_test/flutter_test. dart';而不是直接从测试包导入到我的测试文件中。所以我不需要包含test:在我的出版规范里是1.20.0。

1tuwyuhd

1tuwyuhd2#

尝试在pubspec.yaml文件中将test_API重写为0.4.9:

dependency_overrides:
  test_api: 0.4.9

dependency_overrides:
  analyzer: ^3.0.0

你可以在下次flutter更新的时候删除这个。

14ifxucb

14ifxucb3#

相关性覆盖中添加测试API
示例:

dependency_overrides:
  test_api: ^0.4.17

dev_dependencies:
  flutter_test:
    sdk: flutter
  bloc_test: ^9.1.0
  build_runner: ^2.3.3

相关问题