File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ # C++ | Google Test | Gcov | Lcov
2+
3+ ## Build instructions
4+
5+ ``` shell script
6+ mkdir build
7+ cd build
8+ cmake ..
9+ cmake --build .
10+ ```
11+
12+ This will create two executables: ` main ` and ` test ` in the ` build ` directory.
13+
14+ ## Coverage
15+
16+ 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.
17+
18+ ![ CLion coverage] ( res/images/clion.png )
19+
20+ To view the results with Gcov and Lcov as HTML, follow these commands (while you are still in the build directory):
21+
22+ ``` shell script
23+ ./test # Run the test at least once to generate the .gcda file
24+ cd CMakeFiles/test.dir/src
25+ gcov testsubject.cpp.gcno
26+ lcov --capture --directory . --output-file gtest_coverage.info
27+ genhtml gtest_coverage.info --output-directory CODE_COVERAGE
28+ cd CODE_COVERAGE
29+ ```
30+
31+ Then open the generated ` index.html ` in ` CODE_COVERAGE ` directory to see the results in your browser.
32+
33+ ![ Lcov coverage] ( res/images/lcov.png )
You can’t perform that action at this time.
0 commit comments