lcov for flutter sees just part of files

Viewed 219

I try to use lcov for flutter project in Ubuntu 20.04.

Firstly i run flutter test --coverage, then genhtml coverage/lcov.info -o coverage/html.

But finally only small part of files is mentioned in report. There are no entire subdirectory such as logic, ui, etc, where code is placed too. And even if directory is processed for example named domain it processed partially.

Here is file tree of project Repost contains only small part of files

1 Answers

first, execute this command for create a coverage helper test archive, make sure the test folder is created

file=test/coverage_helper_test.dart
echo  "// Helper file to make coverage work for all dart files\n" > $file
echo "// ignore_for_file: unused_import" >> $file 

then execute this command for create imports of all files of your project o package, replace {YourName} for your name project or package, if you need exclude more extension add '!' -name '*.freezed'

find lib '!' -name '*.md' '!' -name '*.g.dart' -name '*.dart' | cut -c4- | awk -v package=$1 '{printf "import '\''package:{YourName}%s%s'\'';\n", package,$1}' >> $file
echo "void main(){}" >> $file

then run flutter test --coverage

Related