项目作者: reallhy

项目描述 :
gtest, gmock, c++ code coverage report with cmake
高级语言: CMake
项目地址: git://github.com/reallhy/gmock-boilerplate.git
创建时间: 2016-12-02T07:52:59Z
项目社区:https://github.com/reallhy/gmock-boilerplate

开源协议:MIT License

下载


gmock-boilerplate

boilerplate project to show how to test with gtest and gmock

  • how to mock interface with virtual methods
  • how to mock global functions which have no class body
  • how to make code coverage report in the browser
  • how to make cobertura report to integrate with CI Build

Prerequisites

  1. sudo apt-get install cmake gcovr lcov

How to generate Mock class

  1. cd test/generator
  2. ./gmock_gen.py ../../include/Shape.h

How to build

  1. mkdir build
  2. cd build
  3. cmake ..
  4. make gmock-boilerplate_test -j 8

How to test

  1. cd build/test
  2. ./gmock-boilerplate_test

or

  1. cd build/test
  2. ctest -VV

How to make code coverage report

coverage report with browser

  1. cd build
  2. make gmock-boilerplate_coverage
  • open build/coverage/index.html in your favorite browser

cobertura report (xml format supported by Jenkins)

  1. cd build
  2. make gmock-boilerplate_cobertura
  • add build/cobertura.xml to Jenkins Job (should install Jenkins Cobertura Plugin)

License

The code is available under the MIT license.