How to build samples of Google Test?
In the source of google test, it provides some samples to show how to use google test. In this article, we describe how to build these samples.
1. an example to build a sample
The source of google test provides a sample to build its exmaple. It is in ../make.
This example is to build sample1_unittest, it is in ../samples.
The source code to be tested is in file sample1.cc & sample1.h.
The unit test code is in file sample1_unittest.cc.
# /usr/src/gtest-1.5.0
# cd make
# make
# ./sample1_unittest
The result of build is in ../make, then, we can run sample1_unittest, as follows.
root@yu29:/usr/src/gtest-1.5.0/make# ./sample1_unittest
Running main() from gtest_main.cc
[==========] Running 6 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN ] FactorialTest.Negative
[ OK ] FactorialTest.Negative (0 ms)
[ RUN ] FactorialTest.Zero
[ OK ] FactorialTest.Zero (0 ms)
[ RUN ] FactorialTest.Positive
[ OK ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (0 ms total)