【问题标题】:How to disable checks on golden images in flutter test如何在颤振测试中禁用对黄金图像的检查
【发布时间】:2021-07-27 23:30:38
【问题描述】:

我正在尝试在 Flutter 项目上创建 CI 工作流程。 在这些工作流程中,我必须使用 flutter test 运行测试。 由于某些技术原因,我希望能够在某些工作流程中使用黄金映像运行测试,而其他一些工作流程则在忽略所有黄金映像检查的情况下运行测试。

有办法吗?

【问题讨论】:

    标签: flutter dart testing flutter-test


    【解决方案1】:

    您可以使用强烈推荐的金色toolkit

    this answer 中所述,您只需在 test/flutter_test_config.dart 中创建一个文件,其内容如下:

    import 'dart:async';
    import 'dart:io';
    
    import 'package:golden_toolkit/golden_toolkit.dart';
    
    Future<void> testExecutable(FutureOr<void> Function() testMain) async {
      return GoldenToolkit.runWithConfiguration(
        () async {
          await loadAppFonts();
          await testMain();
        },
        config: GoldenToolkitConfiguration(
          // Currently, goldens are not generated/validated in CI for this repo.     We have settled on the goldens for this package
          // being captured/validated by developers running on MacOSX. We may revisit this in the future if there is a reason to invest
          // in more sophistication
          skipGoldenAssertion: () => !Platform.isMacOS,
        ),
      );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-17
      • 2021-09-21
      • 2020-05-04
      • 1970-01-01
      • 1970-01-01
      • 2021-07-22
      • 1970-01-01
      • 2021-10-25
      相关资源
      最近更新 更多