【问题标题】:how to ignore a line in `dart-lang/coverage`如何忽略“dart-lang/coverage”中的一行
【发布时间】:2021-02-12 10:26:41
【问题描述】:

用例

codecov 认为 super 需要测试,

不确定是否为此关键字

编写测试
  • 会很有意义
  • 如何编写这样的测试

我想从coverage 中排除该行,直到我的疑虑得到解决

问题

如何忽略dart-lang/coverage中的一行

【问题讨论】:

标签: flutter dart code-coverage test-coverage codecov


【解决方案1】:

我看到了。不完美,但有解决方案

// coverage:ignore-line to ignore one line.
// coverage:ignore-start and // coverage:ignore-end to ignore range of lines inclusive.
// coverage:ignore-file to ignore the whole file.

【讨论】:

    【解决方案2】:

    widget_tester.dart 的文档中

    testWidgets('MyWidget asserts invalid bounds', (WidgetTester tester) async {
      await tester.pumpWidget(MyWidget(-1));
      expect(tester.takeException(), isAssertionError); // or isNull, as appropriate.
    });
    

    【讨论】:

    • 谢谢,但是 super 呢? [编辑问题] 也......它不是一个小部件
    【解决方案3】:

    目前不可能

    在 dart 和 Flutter 中排除代码覆盖率的行(参见 issue

    我正在消除有关问题的歧义 what is the correct way to test super keyword

    【讨论】:

    • 很多人都说它已修复,但我使用的是最新版本的 Flutter,但似乎仍未修复。我可以忽略整个文件,但不能忽略文件的某些部分。
    猜你喜欢
    • 1970-01-01
    • 2020-03-31
    • 2019-09-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 2012-05-03
    • 1970-01-01
    相关资源
    最近更新 更多