google-test: code coverage

后端 未结 3 1668
鱼传尺愫
鱼传尺愫 2020-12-24 11:10

Is it possible to get code coverage done by tests using google test framework?

3条回答
  •  时光取名叫无心
    2020-12-24 11:58

    Yes, You can club your Gtest Based application with support of Gcov/lcov. refer the documentation of lcov http://ltp.sourceforge.net/coverage/lcov.php

    there is one linux test project utility available which does your job very easy and is very self-interpretative.

    lcov - a graphical GCOV front-end

    Download from Ubuntu repo:

    $ sudo apt-get install lcov
    
    1. Use following commands in your build directory

      $ lcov --directory ./build/ --capture --output-file ./code_coverage.info -rc lcov_branch_coverage=1
      
    2. Run the Application

    3. Generate HTML Report

      $ genhtml code_coverage.info --branch-coverage --output-directory ./code_coverage_report/
      

    This will look something like - http://ltp.sourceforge.net/coverage/lcov/output/index.html

提交回复
热议问题