项目作者: hacksdump

项目描述 :
Google Test coverage report generation
高级语言: CMake
项目地址: git://github.com/hacksdump/googletest-coverage.git
创建时间: 2020-07-31T17:23:15Z
项目社区:https://github.com/hacksdump/googletest-coverage

开源协议:

下载


C++ | Google Test | Gcov | Lcov

This repository demonstrates how to get coverage results with Google Test.

The CMake flag set(CMAKE_CXX_FLAGS --coverage) does the main job.

Build instructions

```shell script
mkdir build
cd build
cmake ..
cmake —build .

  1. This will create two executables: `main` and `test` in the `build` directory.
  2. ## Coverage
  3. If you are using CLion, it becomes really easy to visualize coverage statistics. Just run the test with coverage and Clion will do the job.
  4. ![CLion coverage](res/images/clion.png)
  5. To view the results with Gcov and Lcov as HTML, follow these commands (while you are still in the build directory):
  6. ```shell script
  7. ./test # Run the test at least once to generate the .gcda file
  8. cd CMakeFiles/test.dir/src
  9. gcov testsubject.cpp.gcno
  10. lcov --capture --directory . --output-file gtest_coverage.info
  11. genhtml gtest_coverage.info --output-directory CODE_COVERAGE
  12. cd CODE_COVERAGE

Then open the generated index.html in CODE_COVERAGE directory to see the results in your browser.

Lcov coverage