如何在抖动测试覆盖率中排除文件?

时间:2018-12-06 10:18:03

标签: dart flutter code-coverage flutter-test

我正在尝试从config测试结果的测试覆盖率结果中排除几个文件flutter。当我运行flutter test --coverage时,输出文件icov.info也具有有关config文件的信息,这会影响总覆盖率。

2 个答案:

答案 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