Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude file in flutter test coverage?

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.

like image 634
Jak Avatar asked Dec 06 '18 10:12

Jak


People also ask

How do you exclude files from code coverage?

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.

How do you increase test coverage in flutter?

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.


1 Answers

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
like image 95
René Lazo Avatar answered Sep 18 '22 06:09

René Lazo