【问题标题】:Flutter drive: How to only run one group or testFlutter 驱动:如何只运行一组或测试
【发布时间】:2020-05-12 14:00:42
【问题描述】:

所以在稀缺的introduction to integration testing 中,你应该使用

flutter drive --target=test_driver/app.dart

但是我找不到任何关于只运行特定组或测试的信息。

flutter drive --help

也无济于事。

【问题讨论】:

    标签: flutter dart integration-testing flutter-test


    【解决方案1】:

    或者,您可以在测试运行中添加 --feature 选项

    在 app_test.dart 上

      var parser = ArgParser();
      parser.addOption('feature');
      var results = parser.parse(arguments);
    
      final config = FlutterTestConfiguration()
        ..features = [Glob("test_driver/features/" + results["feature"])]
    
    ....
    

    那么在运行测试时你可以指定--feature your.feature

    【讨论】:

      【解决方案2】:

      虽然似乎没有out of the box 方法/方式只运行一个组或特定测试,但我们可以使用flutter_gherkin 包来实现。这使用了小黄瓜和黄瓜框架的组合,并具有我们可以指定要运行的测试的标签。 你可以阅读更多关于它的信息here

      基本上,在包提供的配置文件中,您可以指定如下内容:

      ..targetAppPath = "test_driver/app.dart"
      ..tagExpression = "@smoke"
      ..exitAfterTestRun = true;
      

      然后像下面这样从终端运行测试:

      dart test_driver/app_test.dart --tags @smoke

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-11-10
        • 1970-01-01
        • 2012-12-27
        • 2019-08-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多