Skip to content

Example project for testing using Google Test and Google Mock

Notifications You must be signed in to change notification settings

KanoComputing/googletest-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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
)

About

Example project for testing using Google Test and Google Mock

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published