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

TypeError when trying to display coverage report #140

Closed swissspidy closed 6 years ago

swissspidy commented 6 years ago

Hey there

I'm running into an issue when trying to use version 2 of this extension with VSCode 1.24 and a coverage report from a PHP project.

I used PHPUnit to create a coverage report in XML (Clover) and set coverage-gutters.xmlname accordingly in the settings.

When I now want to display the coverage, I get the following output:

[1530257529661][coverageservice]: INITIALIZING
[1530259016664][coverageservice]: LOADING
[1530259017522][coverageservice]: Loading 1 file(s)
[1530259017552][coverageservice]: Warning TypeError: Cannot read property 'forEach' of undefined
[1530259017552][coverageservice]: RENDERING
[1530259017552][coverageservice]: READY

Happy to provide access to a sample repo / XML file if needed.

ryanluker commented 6 years ago

@swissspidy thanks for submitting an issue. I will take a look this weekend at adding a small example php project to the examples/ folder and see if I can reproduce it.

swissspidy commented 6 years ago

Awesome, thank you very much! Again, let me know if I can assist with anything.

ryanluker commented 6 years ago

@swissspidy I got a bit further but couldnt figure out how to generate lcov type xml coverage from phpunit? checkout this PR I am working on to see what where I got to https://github.com/ryanluker/vscode-coverage-gutters/pull/141. maybe you could assist in figuring out how to generate something similar to https://github.com/ryanluker/vscode-coverage-gutters/blob/master/example/python/cov.xml as currently the best I was able to get was https://github.com/ryanluker/vscode-coverage-gutters/blob/140-php-support/example/php/cov.xml . The php cov.xml wouldn't load through cobertura-parse though and silently fails inside it's parse file call.

pedroresende commented 6 years ago

@ryanluker I don't think it's possible, because phpunit xml is based on junit. @sebastianbergmann is there another way ?

swissspidy commented 6 years ago

Ah I see, those are quite different.

I guess it's easiest if this format could be converted to lcov. For this I just found https://www.npmjs.com/package/@cvrg-report/clover-json. The code itself looks rather straightforward: https://github.com/cvrg-report/clover-json/blob/ff11325f0543eb4e50c276ee0424365944ee980f/src/index.js

This could fit into LcovParser. Basically:

@cvrg-report/clover-json is licensed under MIT as well, so there shouldn't be any problems.

ryanluker commented 6 years ago

@swissspidy yes that approach sounds like it should work, I will take a first stab at implementing something this weekend in the branch I mentioned earlier. @pedroresende thanks for the extra info around phpunit xml option being junit, I think having the clover option should be enough for most php developers.

ryanluker commented 6 years ago

@swissspidy #141 finally got the php side working, thanks for doing the research and the if else block! It ended up working perfectly https://github.com/ryanluker/vscode-coverage-gutters/pull/141/commits/50ea4fea491d9b69a8ee46143b6df1ab80d5ceb3#diff-3661d843d67f46cb9cfd476ad7e1920cR26 . I will release 2.1.0 this afternoon (pst) to the marketplace and will publish a release to github soon.