Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/delsner/cpp-test-specific-coverage
Obtaining test specific coverage from a Google Test C++ application with OpenCppCoverage
https://github.com/delsner/cpp-test-specific-coverage
Last synced: about 17 hours ago
JSON representation
Obtaining test specific coverage from a Google Test C++ application with OpenCppCoverage
- Host: GitHub
- URL: https://github.com/delsner/cpp-test-specific-coverage
- Owner: delsner
- Created: 2020-02-25T08:31:52.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-28T20:20:38.000Z (almost 3 years ago)
- Last Synced: 2024-11-11T19:42:13.517Z (2 months ago)
- Language: C++
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Test-specific Code Coverage in C++ with OpenCppCoverage
This repository demonstrates the use of OpenCppCoverage to gather coverage per test case in C++ projects using Google's Testing framework.
## Google Test
[Google Test](https://github.com/google/googletest) is Google's C++ test framework used to create test cases.
The [hooks inside Google Test](https://google.github.io/googletest/advanced.html#defining-event-listeners) can be used for implementing the necessary control flow to realize coverage per test case.## OpenCppCoverage
[`OpenCppCoverage`](https://github.com/OpenCppCoverage/OpenCppCoverage) is an open-source tool for obtaining coverage from `.pdb` files as created by MS Visual C++.
It is modified for test-specific coverage in [this fork](https://github.com/delsner/OpenCppCoverage).
## Setup
1. Download `OpenCppCoverage.exe` binary of [fork from OpenCppCoverage](https://github.com/delsner/OpenCppCoverage) (and add to `$PATH` if desired)
2. Clone this repository and build it with `cmake` (you can use the internal version of VS)
3. Make sure you can run `unittests.exe (tests\unittests.exe)` with x64-Debug configuration
4. Navigate to `.\out\build\x64-Debug\tests`, make sure there is a `unittests.pdb` and `unittests.exe` file and execute OpenCppCoverage as follows:
```sh
$ PATH_TO_OPENCPPCOVERAGE\OpenCppCoverage.exe --sources libs --sources tests --excluded_sources tests\cov_listener* --excluded_sources tests\main* --enable_debug_callback -- unittests.exe
```
5. The outputted coverage for each test case should be in `.\out\build\x64-Debug\tests\unittests\runtimedump\`.