I am trying to exclude few config
files from the test coverage results in the flutter
test results. When I run flutter test --coverage
, the output file icov.info
is having information about the config
files as well, which is affecting overall coverage percentage.
Ignore Code Coverage You can prevent some files from being taken into account for code coverage by unit tests. To do so, go to Project Settings > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property.
Running the Tests Flutter has a build-in command to run tests and display the test coverage. It looks as follows. This command will run all tests and create a coverage file for you under coverage/lcov.info. Be aware that the coverage reports might be misleading.
If you are using lcov, you can do:
- 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With