Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include test case descriptions in lcov/genhtml code coverage output

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?

like image 445
luis.espinal Avatar asked Oct 03 '12 21:10

luis.espinal


People also ask

How do I enable branch coverage in LCOV?

You need to re-enable it by either: editing your ~/. lcovrc file (copied from /etc/lcovrc) to change lcov_branch_coverage setting to 1. adding --rc lcov_branch_coverage=1 to your lcov command lines.

What is GCOV and LCOV?

Lcov is a graphical front-end for gcov. It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure. Lcov supports statement, function, and branch coverage measurement.


1 Answers

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
like image 177
user1741356 Avatar answered Dec 01 '22 01:12

user1741356