avatarFred Grott

Summary

This article provides a simple way to generate lcov HTML code coverage reports on Windows for Flutter apps.

Abstract

The article describes how to install the lcov set of Perl scripts on Windows using the MS Windows Chocolatey package manager. After installation, the GENTHML variable is set to the location of the genthml Perl script. The article then explains how to generate an lcov.info file using the flutter test --coverage command, and how to generate an HTML report using the Perl script. The output and resulting HTML reports are shown. The article concludes by mentioning the possibility of automating the project workflow.

Opinions

  • The author believes that generating lcov HTML reports on Windows for Flutter app development is easy using the described method.
  • The author implies that automating the project workflow is important.
  • The author includes a trademark notice, indicating an awareness of intellectual property rights.
  • The author mentions that they are a former Android mobile developer and that they write about Flutter mobile app development, design, and life.
  • The author includes links to their social media profiles.
  • The author mentions a resource for getting the same performance and functions as ChatGPT Plus(GPT-4) but at a lower cost.

Lcov On Windows

Stuck on windows developing Flutter apps and no way to get a html graphical report on code coverage? Let me fix that with a damn easy way to get the lcov set of perl scripts installed on windows and get your code coverage html report in seconds.

Pre-Requirements

You will be using the MS Windows Chocolatey package manager to install the windows port of lcov, install page at:

In your terminal you will type this to install it:

choco install lcov

That will install two things, the strawberry perl distribution and the lcov set of perl scripts. Than set your GENTHML variable to where the genthml perl script of lcov is at which is typically this location:

C:\ProgramData\chocolatey\lib\lcov\tools\bin\genhtml

And, that is it and we are ready to generate some html reports!

Code Coverage HTML Reports

You already did this command in your terminal:

flutter test --coverage

and that gave you a lcov.info file in the coverage folder. Now it’s time to generate the html report, in your terminal type:

perl %GENHTML% -o coverage\html coverage\lcov.info

and that will produce this output:

and the html reports look like:

and the main.dart file itself with coverage marked:

Conclusion

That is how to get locv html reports the easy way on windows for flutter app development. But, what about automation of the project workflow?

That is why these mini-articles are leading to in my next big article.

Resources

Resources specific to the article:

windows port of lcov@chocolatey https://chocolatey.org/packages/lcov

General Flutter and Dart resources:

Flutter Community Resources https://flutter.dev/community Flutter SDK https://flutter.dev/docs/get-started/install Android Studio IDE https://developer.android.com/studio MS’s Visual Studio Code https://code.visualstudio.com/ Flutter Docs https://flutter.dev/docs Dart Docs https://dart.dev/guides Google Firebase Mobile Device TestLab https://firebase.google.com/docs/test-lab

Trademark Notice

Google LLC owns the following trademarks; Dart, Flutter, Android, Roboto, Noto. Apple Inc owns the trademarks iOS, MacOSX, Swift, and ObjectiveC. Apple Inc owns trademarks to their fonts of SF Pro, Sf Compact, SF mono, and New York. JetBeans Inc owns the trademarks to JetBeans, IntelliJ, and Kotlin. Oracle Inc owns the Java trademark. Microsoft Inc owns the trademarks to MS Windows OS and Powershell. Gradle is a trademark of Gradle Inc. The Git Project owns the trademark to Git. Linux Foundation owns the trademark to Linux. SmartPhone OME’s own trademarks to their mobile phone product names. To the best of my ability I follow the brand and usage guidelines with the above mentioned trademarks.

About Fred Grott

I’m the crazy SOB who as a former android mobile developer is starting to write about flutter mobile app development, design, and life(see Eff COVID and GOP https://fredgrott.medium.com/eff-covid-and-the-gop-e912db0548b8). Will I reach the pivotal One Million Medium monthly viewers mark? Sit-back and watch it happen. Find me on these social platforms:

https://twitter.com/fredgrott

Flutter
Lcov
DevOps
Windows
Perl
Recommended from ReadMedium