3

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

Valery Kulikov
  • 319
  • 1
  • 12
  • 1
    Read this https://medium.com/flutter-community/how-to-actually-get-test-coverage-for-your-flutter-applications-f881c0ae8155 – Er1 May 17 '22 at 07:23

1 Answers1

0

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