-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00-README.unittest
52 lines (38 loc) · 1.54 KB
/
00-README.unittest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Support for using google unit test and google mock in openSAF. Using unit test and mocking during e.g. refactoring
to identify units and make code unit testable should improve the overall code quality and robustness.
Regarding google unit test, see:
https://code.google.com/p/googletest/
To get and install google test do the following:
git clone https://github.com/google/googletest.git
cd googletest
autoreconf -vi
./configure --with-pthreads
make -j 4
export GTEST_DIR=`pwd`/googletest
export GMOCK_DIR=`pwd`/googlemock
configure openSAF as usual, for example:
./bootstrap.ch
./configure CFLAGS="-DRUNASROOT -O2" CXXFLAGS="-DRUNASROOT -O2" --enable-tipc
make -j 4
To build and run the unit tests
make check
A unit test report will be written on the console. Unit test logs etc. can be found under the tests directory.
Gtest unit test code to be placed at each service under service/saf/"service"/tests, example:
services/saf/amf/
├── amfd
│ ├── include
│ ├── scripts
│ └── tests
├── amfnd
│ ├── include
│ ├── scripts
│ └── tests
├── amfwdog
│ ├── scripts
│ └── tests
└── config
The test code to have the following naming convention as below:
tests will be in file xxxx_test.cc, where xxxx is the name of the unit test case,
mocks will be in file mock_xxxx.cc, where xxxx is the name of the mock.
No need to call the RUN_ALL_TESTS() macro, it is included in gtest_main and gmock_main
and are automatically linked with the unit test cases.