ryanluker / vscode-coverage-gutters

Display test coverage generated by lcov and xml - works with many languages
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
MIT License
460 stars 88 forks source link

Add support for Dart/Flutter #291

Closed Ascenio closed 3 years ago

Ascenio commented 3 years ago

Is your feature request related to a problem? Please describe. It would be nice if the extension could be compatible with both Dart and Flutter.

Describe the solution you'd like Well, once you run flutter test --coverage you get a folder in the root named coverage which contains lcov.info. The rest you know.

Describe alternatives you've considered I have thinked about using a CI/CD thing but it would be nice to have coverage integrated with vscode.

ryanluker commented 3 years ago

@Ascenio Thanks for creating a ticket! There was a bit of discussion for flutter / dart in the past https://github.com/ryanluker/vscode-coverage-gutters/issues/160 might be useful to look through there for some ideas to your issue if we cant solve it below.

Do you have an example project that we can see the outputed lcov.info for? I would think if flutter / dart generate an lcov.info file that is to the specification then the extension should "just work". Also the extension already finds any files that are named lcov.info and tries to load them.

Could you look into the gutter logs in your vscode and see if anything is being loaded? image

After a quick bit of googling it seems others have got it working (with other vscode coverage extensions but the process of setting up the lcov.info might help). http://blog.wafrat.com/test-coverage-in-dart-and-flutter/

Ascenio commented 3 years ago

Firstly, that was quick, thanks for you support.

After I enabled the watch option it seems to be working at displaying the covered and not covered parts, however, it can't show the preview coverage report. It opens that prompt to select a file but there's none to be selected. Preview coverage report demo The funny thing is it totally detected the lcov file, but why the report thing doesn't agree with me? ;(

Ascenio commented 3 years ago

Have some logs :page_facing_up:

jamieastley commented 3 years ago

@Ascenio it seems the coverage report only support html-exported reports.

If you run flutter test --coverage to generate the .lcov, and then genhtml coverage/lcov.info -o coverage/html, the extension is then able to display the generated html reports.

ryanluker commented 3 years ago

@jamie1192 Thanks for giving another alternative. You are correct that currently the extension only supports previewing html coverage reports. @Ascenio Hopefully that helps and let me know if we can close this ticket with the above workaround. (sorry for the late reply as well, you caught me doing my weekly checks last time thus the quick turnaround!)

jamieastley commented 3 years ago

image

@ryanluker It may still be worth noting that while it can display the report, any images/icons fail to render. Though I think this is a VSCode issue as it doesn't seem to like relative paths for anything, just the other day I was trying to get markdown images to display within Dart doc and it only works with absolute paths, not project relative paths :/

Ascenio commented 3 years ago

Hello, it has been a while. I don't know what was the problem before but now it seems to be working, I'm using a plain .lcov file and looks like it matches what the html version shows. Thanks for you support, guys. :v: