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

where do i put lcov file? #77

Closed sinh927 closed 7 years ago

sinh927 commented 7 years ago

I ran angular test with coverage. The file has been created. However, this plugin does not work. why?

ryanluker commented 7 years ago

hello sinh, do you have a custom named lcov file by chance? you can define a partial path / file name by using the coverage-gutters.lcovname setting. Can you also try and check out this project and run the example project tests and see if you can see the coverage then? To assist in the debugging could you also give the partial file path to the file you mentioned?

pintocarlos commented 7 years ago

I'm also running into the same issue. I am using nyc https://www.npmjs.com/package/nyc lcov reporter option nyc --reporter=lcov which generates the following file structure:

screen shot 2017-07-15 at 1 09 09 am

Is this what the extension is expecting or is it something different? I'd love to try this extension, please advise. Thanks!

pintocarlos commented 7 years ago

I tested your example project and it works correctly. Im going to assume that you depend on the coverage.json file and not on the lconv.info, which I believe is the more common one.

Any plans on supporting the text file instead of the json file only?

EDIT: Ok nevermind, I was able to output the same .json file using nyc which has access to all istabul reporters and was still unable to get the extension detecting it. I also tried setting a file name in the settings option coverage-gutters.lcovname and still no luck.

Is this setting expecting the file to already be inside the coverage folder or no?

This is my npm test script if you'd like to try it locally:

"test": "NODE_ENV=test nyc --clean --reporter=lcovonly --reporter=json --reporter=text mocha test/setup.js --recursive 'test/*/*.spec.js' --reporter spec"
ryanluker commented 7 years ago

hey @pintocarlos thanks for bringing more information to this issue. currently the extension only supports the lcov.info files (as you mentioned they are the more common) but this file can be anywhere inside the root of your project (see https://github.com/ryanluker/vscode-coverage-gutters/blob/2e8565fa1515ae29806bc673892709b3f6ce99b0/src/lcov.ts#L27 for the blob find of the file).

The lcov name setting you mentioned allows you to specify another name for the blob search to look for, within the root path of the project. ie: "coverage-gutters.lcovname": "yourcustomlcovnamehere.info"

I also couldnt get nyc to produce coverage for my example project either... I do use nyc to produce coverage in other projects though and the extension works on those. Let me know if you get an further.

pintocarlos commented 7 years ago

Hi @ryanluker I figured out what the problem was. First of all it was not related to the location of the file. I ended up leaving the settings option empty and letting it use the default path: coverage/lconv.info.

The issue is that the extensions "Watcher" will not start parsing the code coverage in the lcov file unless you are currently in a file that actually has tests and is covered by the lcov file.

Take for instance the following scenario:

In essence, I think what would be great is if you check if no watcher is running, then try to enable it once a file is opened file if that file has coverage in the lconv file.

I hope this helps. Thanks, Carlos

ryanluker commented 7 years ago

@pintocarlos thanks for the extra info! In the 1.1 release (coming soon) the watch will always start now, see code here if interested, which should facilitate the flow you mentioned! I will leave this ticket open until shortly after the next release before closing it (if you or sinh has further issues you can always open another ticket 😄 )

andreas-lundgren-qlucore commented 1 month ago

Hi @ryanluker I figured out what the problem was. First of all it was not related to the location of the file. I ended up leaving the settings option empty and letting it use the default path: coverage/lconv.info.

The issue is that the extensions "Watcher" will not start parsing the code coverage in the lcov file unless you are currently in a file that actually has tests and is covered by the lcov file.

Wow, you're the best! I was picking some top rated tool and ended up with the same combo, and this comment really made it work!

ryanluker commented 1 month ago

Hi @ryanluker I figured out what the problem was. First of all it was not related to the location of the file. I ended up leaving the settings option empty and letting it use the default path: coverage/lconv.info. The issue is that the extensions "Watcher" will not start parsing the code coverage in the lcov file unless you are currently in a file that actually has tests and is covered by the lcov file.

Wow, you're the best! I was picking some top rated tool and ended up with the same combo, and this comment really made it work!

Excellent, glad to see comments from +7 years ago proving useful!