flutter-coverage icon indicating copy to clipboard operation
flutter-coverage copied to clipboard

Add option to exclude files (file patterns) from the calculation

Open ghost opened this issue 4 years ago • 1 comments

Hi,

for me it would be nice to have the option to specify files or patterns that will be excluded from the coverage calculation. In my project there are some parts which are very hard to test.

Would be nice if you could implement something :)

ghost avatar Oct 29 '21 19:10 ghost

Yeah, it would be pretty nice to have an extension property such as flutter-coverage.excludedPatterns, or something like that.

However, there is already an unpleasant method you can rely on to achieve this result, that is, removing those files just after you've built the lcov file. The following is an example in which all generated files that end with ".g.dart" are removed from the coverage count, and then the original lcov.info file is replaced with the updated one:

lcov --remove coverage/lcov.info 'lib/**/*.g.dart' -o coverage/lcov.info
genhtml coverage/lcov.info --output=coverage

TheFabbiusCorp avatar Feb 06 '22 17:02 TheFabbiusCorp