Flutter 忽略覆盖范围注释并不总是有效
// coverage:ignore-line
// coverage:ignore-start
// coverage:ignore-end
不要总是工作。
我使用上面的注释来通知测试人员忽略测试覆盖率中的行以实现 100% 的代码覆盖率。但这些评论只在某个地方有效,而且表现得很奇怪。
我尝试了所有方法来忽略代码中的该行,但未能获得预期结果。
在上图中,您可以看到即使添加 //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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论