Skip to content

Commit acaaf9d

Browse files
committed
add readme
1 parent 25f18dd commit acaaf9d

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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)

res/images/clion.png

36 KB
Loading

res/images/lcov.png

156 KB
Loading

0 commit comments

Comments
 (0)