javascriptsonarqubecode-coveragetest-coveragelcov

Is lcov file which has 2 other lcov files simply concatenated a valid lcov file?


I have 2 lcov report files I want to concatenate to send to Sonar instance. One if from unit tests and second one is from e2e tests ( Selenium ).

So I intend to do

cat unit.lcov >> e2e.lcov

Is this valid or structure of new lcov file will be not valid/correct/parsable and I should use some other dedicated tool? ( I know about https://www.npmjs.com/package/lcov-result-merger )


Solution

  • Late answer - sorry. Generally: yes. That will work - but it will also depend on the next tool in the chain knowing how to merge matching file names in the concatenated result. lcov/genhtml know - but other tools may not.

    A safer technique is to use "lcov --add ..." to create an aggregate result. This approach also gives you the opportunity to filter or otherwise munge your coverage data during aggregation.