Getting Code Coverage %

237 views
Skip to first unread message

Chris

unread,
Feb 8, 2024, 3:52:03 AM2/8/24
to ThrowTheSwitch Forums
Hi folks,

I'm new to Unity and unit testing in general. Sorry to be a pain, but could someone point me to where in the docs it advises how to get out put of code coverage % after running tests? I can't seem to find it myself.

Many thanks,

Chris

Mark Vander Voord

unread,
Feb 8, 2024, 10:08:43 AM2/8/24
to throwth...@googlegroups.com
Hi Chris:

Unity itself is just a test framework and won't directly provide test coverage. Coverage tools (like gcov) team up with test frameworks to get the answers you're looking for. They do this by instrumenting your code with extra hidden calls when you compile to keep track of all the information required.

If you're using Ceedling to manage your builds, you can enable the :gcov or :bullseye plugins. Check the documentation for these plugins and it'll explain the usage and reporting options, etc.

If you're managing your own builds, either tool is still an option, but you'd need to set it up yourself. The documentation on those particular tools' websites should explain how they work. The only "trick" past that is that you will want to configure the tools to report coverage for your source files, not unity, cmock, runners, or test files. There are settings for this, so that your coverage reports show the things you actually care about.

Best of luck!

Mark

--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/throwtheswitch/0a5fde66-9b55-43ba-9217-8fac5a43b4f4n%40googlegroups.com.

Chris

unread,
Feb 12, 2024, 5:42:37 AM2/12/24
to ThrowTheSwitch Forums
Hi Mark, Thanks for getting back to me!

This is great, and helps point me in the correct direction. Really appreciate the time you took to provide the answer.

Best,

Chris
Reply all
Reply to author
Forward
0 new messages