Code Coverage for SonarQube

I am having a challenge trying to figure out what exactly SonarQube is expecting for a code coverage text file that - when accepted by the SonarQube SW - would yield code coverage on the resulting project.

So to keep this simple, an example: let’s say my project only has a main.c (my application is C based), assume no other files. Let’s say that file has 22 lines of source code, 2 branches. My unit testing yields 100% coverage and yes, each branch is exercised both ways (branch taken/branch not-taken). For this simple example, what would be the expected content of the code coverage text file that would satisfy SonarQube to display code coverage for this module?

I am assuming the text file would contain something like:
main.c 22 2/2 100%
…but cannot find ANY documentation for what the EXACT format of that file needs to be.

Any help with this SIMPLE example would be appreciated.

Thanks,

JProf

Hi JProff,

Welcome to the community!

We document pretty thoroughly which tools’ reports we accept.

If you don’t want to use the tools themselves, just pick one and match its format.

 
HTH,
Ann

That has not helped me, as I have had some cases where it say rejects the input text file because it has a magic character it didn’t like (say a “-” or whatever). And I have toyed with the input and had SonarQube claimed it accepted it, but when I reviewed the code coverage…still 0% for all files.

In my original post, I gave a very specific, very simple usage case, 1 file (main.c) 22 lines of code 2 branches and branches exercised both ways each. One of the experts here should be able to tell me what the content of that code coverage text file would look like.

I asked a very simple question there which seems nobody can find an answer to…I have studied the various links/etc for what to do and how to import code coverage into SonarQube. We’ll just keep down our path where nobody can give me a specific example.

A suggestion: create and post on say github projects where the code coverage input text file is ALSO posted. None of the examples I saw on github for SonarQube code coverage seem to have that file that it imports to resolve code coverage.

If you were to ask me for some sample code, I would not send you off to go look on the internet with the notion that you would just figure it out. I would give you some code. Please think about that….

~WRD0000.jpg