Question

I'm using lcov to generate code coverage reports for a C code base. I would like to integrate test descriptions into the final output (using lcov's gendesc utility.)

However, I have no clue on how to do that, and documentation on gendesc seems rather sparse (as far as the good old google has been able to tell me.)

The gendesc info at LTP describes how to create the input test case description files (as expected by genhtml). And the genhtml info provides --show-descriptions, and --description-file for inputting such test case description files.

However, I don't know how to reference the test cases so that they get included in the final report. genhtml sees them as unused test cases and thus keeps them out of the generated html output. I can use --keep-descriptions, but that doesn't tell me what test cases were run (obviously because I do not know how to make the reference from code to test description.)

So, how do we tell lcov/genhtml which tests were run in the final output? Any ideas?

Was it helpful?

Solution

To associate a test case name with coverage data, specify that name while collecting coverage data using lcov's --test-name option:

lcov --capture --directory project-dir --output-file coverage.info --test-name "test01"

Then continue with the steps that you already mentioned, that is create a test case description file "tests.txt":

test01
    Some test

Convert it into the format expected by genhtml:

gendesc tests.txt --output-filename tests.desc

Finally specify the descriptions file to genhtml:

genhtml coverage.info --output-directory out --description-file tests.desc --show-details
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top