https://github.com/kanocomputing/googletest-sample
Example project for testing using Google Test and Google Mock
https://github.com/kanocomputing/googletest-sample
Last synced: 9 months ago
JSON representation
Example project for testing using Google Test and Google Mock
- Host: GitHub
- URL: https://github.com/kanocomputing/googletest-sample
- Owner: KanoComputing
- Created: 2018-04-25T15:42:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-25T15:58:41.000Z (about 8 years ago)
- Last Synced: 2025-04-04T01:51:06.977Z (about 1 year ago)
- Language: C++
- Size: 6.84 KB
- Stars: 15
- Watchers: 19
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sample google-test project
This is a sample project using the Google Test/Google Mock framework with
some examples of a few tests.
The framework is well documented at:
* [Google Test](https://github.com/google/googletest/blob/master/googletest/docs/Documentation.md)
* [Google Mock](https://github.com/google/googletest/blob/master/googlemock/docs/Documentation.md)
## Requirements
In order to get things working, you will need:
* C++ compiler (ideally C++11 compatible)
* Make
* CMake (> 2.8.11)
## Building
Compile with:
```
> cmake .
> make
```
Run main executable:
```
> ./sample
```
Run tests:
```
./tests/tests
```
You can build and run the tests all this with one line:
```
> cmake . && make && ./tests/tests
```
## Structure
```
./
├── CMakeLists.txt // Main project CMake definition
├── src/ // Program to test
│ ├── main.cpp // Program entrance point
│ ├── *.cpp // Class definitions
│ ├── include/
│ └── *.hpp // Header files
└── tests/ // Tests
├── CMakeLists.txt // CMake file for tests
├── src/
│ ├── fixtures/
│ │ └── *.hpp // Fixture definitions
│ ├── mocks/
│ │ └── *.hpp // Mock definitions
│ ├── tests.cpp // Test program definition
│ └── *.cpp // Tests
└── vendor/ // 3rd-party google-test framework
```
## How to modify
To add new source files, create the files in the `./src/` and `./src/include`
directories and add an entry into the `./CMakeLists.txt` file for each new `.cpp` file.
```
add_executable(
sample
src/main.cpp
...
src/my_new_file.cpp
)
```
To add new test files, create the files in the `./tests/src/` and
`./tests/src/include` directories and add an entry into the
`./tests/CMakeLists.txt` file for each new `.cpp` file.
```
add_executable(
tests
src/tests.cpp
...
src/my_new_test.cpp
)
```