How to get code coverage of a library from unit tests
Last edited on
We suppose that the project contains N libraries in the directories
libprojN. Each library generated are static libraries, and they are
generated in libprojN. We have N unit tests, all of them are
located in testprojM directories.
So the directory tree looks as follows:
First we need to execute the unit tests:
After execting this bash script, a .csexe file is created for each
We import then each testprojM.exe.csexe file into its
Now, the files testprojM.exe.csmes contain the coverage information
of the unit tests and the libraries that were tested. The files
testprojM.exe.csexe are deleted because they are no longer needed.
It is now possible to import the coverage information of the unit
tests into the .csmes file of each tested library:
This script imports into each file libprojN.a.csmes all its unit
test results. The -i command line option lets cmmerge ignore the
source files which are not present in libprojN.a.csmes. This way,
the test code is ignored during the merge process.
We would like to use Google Analytics to get a better understanding of how
you use the website.
By agreeing to this, your usage data will be stored in the USA and processed
by Google LLC. Both Google as well as federal US agencies can access this data
and combine it with any other data about you, such as your search history,
personal accounts or any other data known to Google.