Jak*_*Jak 8 code-coverage dart flutter flutter-test
我试图从测试结果中的测试覆盖率结果中排除几个config文件flutter。当我运行时flutter test --coverage,输出文件icov.info也包含有关config文件的信息,这会影响整体覆盖率。
小智 19
最正确的答案是使用预定义的注释,这些注释将在生成 lcov.info 文件时排除文件。
// coverage:ignore-file
Run Code Online (Sandbox Code Playgroud)
// coverage:ignore-[start/end]
Run Code Online (Sandbox Code Playgroud)
// coverage:ignore-line
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅 GitHub 问题: https://github.com/dart-lang/coverage/issues/162#issuecomment-702950122
有一个方便的包可以做到这一点remove_from_coverage
https://pub.dev/packages/remove_from_coverage
这是使用帮助:
Remove files with paths matching given PATTERNs from the lcov.info FILE
-f, --file=<FILE> the target lcov.info file to manipulate
-r, --remove=<PATTERN> a pattern of paths to exclude from coverage
-h, --help show this help
Run Code Online (Sandbox Code Playgroud)
dev_dependencies如果您想在管道中运行它或全局安装它,基本上将其添加到您的中。
如果您使用 lcov,您可以执行以下操作:
- flutter test --coverage
- lcov --remove coverage/lcov.info 'lib/mock/*' 'lib/utils/l10n/*' 'lib/utils/colors.dart' -o coverage/new_lcov.info
- genhtml coverage/new_lcov.info --output=coverage
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3242 次 |
| 最近记录: |