I'm making Widget and Unit testing on my app, I make the tests normally, according to the basic guides, and to generate the coverage I use:
flutter test --coverage
However I just can see the coverage of the files directly tested, I'd like to see the other files (with 0% of coverage), then I could check the real coverage of my code.
Is there a way for doing that?
I have created a small helper script to help with the full coverage report generation. It scans your lib
directory for *.dart
files (excluding *.g.dart
) and imports them into the generated test/coverage_test.dart
file. Having this generated file coverage analyser will go through the whole project next time you run it. To use the script:
Clone it to any location
wget https://raw.githubusercontent.com/priezz/dart_full_coverage/master/dart-coverage-helper
Make it executable
chmod +x dart-coverage-helper
Ensure that the location of the script is in your PATH
environment variable (or just put it into the root of your project).
Run from the root of your Dart/Flutter project
dart-coverage-helper
Then generate the coverage report as usual
flutter test --coverage # for Flutter project
# or
pub run test_coverage # for Dart project
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