Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Code coverage when mock is used #934

Open
flamingvines2 opened this issue Sep 25, 2024 · 3 comments
Open

Empty Code coverage when mock is used #934

flamingvines2 opened this issue Sep 25, 2024 · 3 comments

Comments

@flamingvines2
Copy link

flamingvines2 commented Sep 25, 2024

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
Copy link
Author

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

@mkarlesky
Copy link
Member

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.

@Letme
Copy link

Letme commented Nov 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants