Partial test coverage

Sonarqube test coverage report says that my c++ statement are only partially covered. Example of a very simplified function containing such statements is as below:

std::string test(int num) {
	return "abc";
}

My test as follow:

TEST(TestFunc, Equal) {
    std::string res = test(0);
    EXPECT_EQ (res, "abc");
}

Sonarqube coverage report says that the return stmt is only partially covered by tests (1 of 2 conditions). I am wondering what is other condition that i need to test for?

I also saw the following in the report:

Condition to cover: 2
Uncovered Condition: 1
Condition Coverage: 50%

It seems like i need a test to cover the other condition but i cant figure out what that is.

Hi @joonhwa,

SonarQube just imports the report, it is out of its control. I would suggest you to open the report and verify manually and do some investigations outside of SonarQube.

We’re also experiencing the same issue with our C# code. We run the build in a docker container so we don’t have access to the build after the container is finished. We’re using opencover, and the appropriate path for that. The generated file is called cover.xml. Is there anyway for SonarQube to link to that file, similar to the way we get the information from dependency-checker plugin?

Hi @BermudaLamb ,

please start a new topic for your issue.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.