Flutter 忽略覆盖范围注释并不总是有效

发布于 2025-01-09 07:00:09 字数 1641 浏览 3 评论 0原文

// coverage:ignore-line
// coverage:ignore-start
// coverage:ignore-end

不要总是工作。

我使用上面的注释来通知测试人员忽略测试覆盖率中的行以实现 100% 的代码覆盖率。但这些评论只在某个地方有效,而且表现得很奇怪。

我尝试了所有方法来忽略代码中的该行,但未能获得预期结果。

//覆盖范围:ignore-line不起作用

覆盖范围不起作用

在上图中,您可以看到即使添加 //coverage:ignore -line//coverage:ignore-start //coverage:ignore-end 报告无法忽略该行,并且以红色显示。这会降低代码覆盖率。

我还注意到,当存在 lambda 函数或多个类和数据类型时,它会失败。

如何才能实现100%的代码覆盖率?有什么办法可以解决这个问题?

下面是我的 flutter 和 dart 版本

Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5f105a6ca7 (3 weeks ago) • 2022-02-01 14:15:42 -0800
Engine • revision 776efd2034
Tools • Dart 2.16.0 • DevTools 2.9.2

PS:我已经关注并阅读了几乎所有的 GitHub 讨论,但仍然一无所获。

https://github.com/flutter/flutter/issues/76544

https://github.com/dart-lang/coverage/issues/162

https://github.com/flutter/flutter/pull/61408

https://github.com/dart-lang/coverage/issues/340

等等

// coverage:ignore-line
// coverage:ignore-start
// coverage:ignore-end

Do not work always.

I am using the above comments to notify the tester to ignore the lines from test coverage to achieve 100% code coverage. But these comments work only at someplace and behave strangely.

I tried all the ways to ignore the line from my code but failed to get the expected result.

//coverage:ignore-line not working

coverage range not working

In the above images, you can see that even after adding //coverage:ignore-line and // coverage:ignore-start // coverage:ignore-end the report is not able to ignore the line and it is shown in red color. This decreases the code coverage percentage.

I have also noticed that it fails when there is a lambda function or multiple classes and datatypes.

How can we achieve 100% code coverage? What can be a workaround to this?

Below is my flutter and dart version

Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5f105a6ca7 (3 weeks ago) • 2022-02-01 14:15:42 -0800
Engine • revision 776efd2034
Tools • Dart 2.16.0 • DevTools 2.9.2

PS: I have followed and read almost all the GitHub discussions but still nothing.

https://github.com/flutter/flutter/issues/76544

https://github.com/dart-lang/coverage/issues/162

https://github.com/flutter/flutter/pull/61408

https://github.com/dart-lang/coverage/issues/340

and many more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文