Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

Empty Code coverage when mock is used

Open flamingvines2 opened this issue 1 year ago • 1 comments

Hi,

I have 2 source (main and driver) that I am generating a coverage report using gcovr. Main doesn't use any mocks while driver use mock. I don't have any issue generating the coverage for main. However, driver has an empty coverage.

Please see attached for details. My build log out.txt project.yml.txt My source files driver.c.txt driver.h.txt

My versions are: Ceedling:: 0.31.1 Unity:: 2.5.4 CMock:: 2.5.4 CException:: 1.3.3 gcovr 4.1

I would appreciate if anyone can point me to what is wrong in my setup or code.

FYI: This is a duplicate of Link. Not sure which is the correct place for this since I am triggering gcovr via Ceedling. I will gladly remove one of them if inappropriate.

Thanks, Carlo

flamingvines2 avatar Sep 25 '24 05:09 flamingvines2

There was no output for driver (driver.o). Probably the reason why gcov is saying no coverage. Wondering what is wrong with it?

flamingvines2 avatar Sep 26 '24 05:09 flamingvines2

Hi, @flamingvines2. Support for 0.31.1 is soon going away as we're preparing to release 1.0.0. Many, many improvements have been made that address a variety of Gcov issues like this. I'd suggest starting there. If you visit the releases list for Ceedling you'll find lots of links to new documentation surrounding the prerelease. There's a cheatsheet in the Release Notes that explains changes to your project configuration needed with the newer versions.

mkarlesky avatar Nov 01 '24 17:11 mkarlesky

Just in case there are more people interested in this issue. Since you did not paste the test_driver.c code, I am betting there you have #include "mock_driver.h". That means that real driver.c implementation is never called, because it calls mock. So my assumption is, that you never actually call driver.c functions, but just the mocks.

So replace mock_driver.h include with driver.h include in test_driver.c and you should get coverage - as well as you will be testing real implementation and not just mock sequence.

Letme avatar Nov 24 '24 15:11 Letme

There are other issues tracking gcov coverage with 1.0.x at this point. We're assuming this particular issue has been resolved.

mvandervoord avatar Jan 22 '25 23:01 mvandervoord