我正在尝试从config
测试结果的测试覆盖率结果中排除几个文件flutter
。当我运行flutter test --coverage
时,输出文件icov.info
也具有有关config
文件的信息,这会影响总覆盖率。
答案 0 :(得分:2)
有一个方便的软件包可以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
如果要在管道中运行它或将其全局安装,则基本上将其添加到dev_dependencies
中。
答案 1 :(得分:2)
如果您使用的是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