OpenCppCoverage | OpenCppCoverage is an open source code coverage tool | Unit Testing library
kandi X-RAY | OpenCppCoverage Summary
kandi X-RAY | OpenCppCoverage Summary
OpenCppCoverage is an open source code coverage tool for C++ under Windows. The main usage is for unit testing coverage, but you can also use it to know the executed lines in a program for debugging purpose.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of OpenCppCoverage
OpenCppCoverage Key Features
OpenCppCoverage Examples and Code Snippets
Community Discussions
Trending Discussions on OpenCppCoverage
QUESTION
I want to use the OpenCppCoverage to check the coverage of my source files by my Unit Test. However, it seems that I need to have .pdb files generated for OpenCppCoverage to work.
The problem is that I am not being able to generate such files from my build. Here is my CmakeLists.txt
...ANSWER
Answered 2021-Oct-19 at 19:00I was able to figure out myself. So here is the answer if someone struggles with the same: gcc compiler is not able to generate .pdb files. What can be done is the following:
- Convert the debug information from gcc to pdb files using the converter called cv2pdb
- Use llvm/clange compiler that has support to generate .pdb
- Use another code coverage tool, such as gcov from gcc itself
I decided to use option 3, and replace opencppcoverage by gcov (in fact I am using gcovr). I had to include the extra flags for coverage as mentioned above:
QUESTION
I am using Google test framework for C++ unit tests. We are building our projects using MsBuild (runs on teamcity). Now, I want sonarqube to parse the coverage info. We have cfamily plugin in sonarqube. The compatible reports with cfamily plugin are bullseye, vscoverage, gcov, llvm-cov. As per my knowledge, because we can't use gcc for compiling, llvm-cov and gcov are ruled out. Since we are using googletest and also wants to run this on teamcity, vscoverage isn't possible. We aren't using Bullseye. (It is more for functional automation I am told).
So I have decide to use OpenCppCoverage tool. This can generate coverage in cobertura format or generic format specified by sonarqube. I have tried generic format but sonarqube is ignoring the coverage for files but is parsing them successfully.
Exploring more, I tried to use C++ community plugin(cxx). But I wasn't able to disable cfamily plugin so that C++ community can be used.
So I want to know if I can do something else so that coverage of our C++ test projects can be parsed by sonarqube.
...ANSWER
Answered 2020-Oct-27 at 13:33Did you try sonar-cxx plug-in from SonarOpenCommunity. This plugin adds C++ support to SonarQube. It's free plug-in and availble with LGPL-3.0 License.
QUESTION
I have large c++ application with complex directory structure. Structure is so deep that code repository can't be stored in Jenkins workspace, but is some root directory, otherwise build fails since path length limit is busted.
Now since application is tested in different environments, test application is run in diffrent machine. Application and all resources are compressed and copied to test machine where tests are run using OpenCppCoverage
and as a result Cobertura xml is produced.
Now since source code is needed to show covarage result xml is copied back to build machine and then feed to Jenkins Cobertura plugin.
ProblemCoverage reports shows only percent results for module or source code. Code content is not show, but this error message is show:
SourceSource code is unavailable. Some possible reasons are:
- This is not the most recent build (to save on disk space, this plugin only keeps the most recent build’s source code).
- Cobertura found the source code but did not provide enough information to locate the source code.
- Cobertura could not find the source code, so this plugin has no hope of finding it.
- You do not have sufficient permissions to view this file.
Now I've found this SO answear which is promising:
The output xml file has to be in the same folder as where
...coverage
is run, so:
ANSWER
Answered 2020-Jan-31 at 13:28Ok I've found reasons why I had a problems with this plugin.
xml from
openCppCoverage
is just correct. No changes are needed here to make it work (as far as sources are there where pdb file points to). Sources outside Jenkins workspace are not the problem here. When I copied executable from build machine to test machine, then run tests withopenCppCoverage
and copied result back to build machine it is just fine.In job configuration any user which supposed to view code coverage has to have access to
Job/workspace
in security section. In my case I've enabled this for all logged in users. This covers last bullet point of error message.Most important thing: build must be successful. I mean form beginning to the end. Doesn't meter if step containing call to cobertura plugin was successful. If any step (even in the future step) fails then cobertura will not show code for this coverage run. In my case build job was failing since one of tests was timing out. This was caused by
openCppCoverage
overhead which slows down tests by factor3
. My script was detecting timeout and killing one of tests.
I discovered that not successful build was a problem by accident. During experiments I noticed two cases when cobertura has shown source code:
- I've rerun job and removed all steps but one responsible for publishing coloratura results
- I run whole job such way it run a single test case which passed
Not sowing coverage if build is not successful is reasonable (if test failed then most probably wrong branch of code has been taken), but UI should indicate that in different way.
ConclusionThis is great example how it is important to report errors to user with precise details what went wrong and why. I wasted at least whole weak to figure out what is actually wrong which bullet point of error message is actually my case. In fact error message from plugin doesn't cover all reasons of not showing the code.
I will file report that plugin should give better explanation what went wrong.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install OpenCppCoverage
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page