This project focuses on performing integration tests for all endpoints of a server implemented in C++. Integration tests are a type of test that verify the interaction between various components of a system to ensure their proper functioning together.
The project utilizes the following tools for conducting integration tests:
-
Google Test: Google Test is a unit testing framework for C++. In this project, it's used to write and execute automated tests that verify the behavior of the server endpoints.
-
CPR: CPR is a C++ library that facilitates HTTP requests. It's used in this project to send requests to the server endpoints during integration testing.
-
nlohmann/json: nlohmann/json is a C++ library for JSON data handling. In this project, it's used to manipulate input and output data of the endpoints during integration testing.
The primary objective of this project is to ensure that all server endpoints function correctly and integrate properly with other components of the system. This is achieved through the writing and execution of automated tests that cover different scenarios and use cases.
The project is organized into different files and folders, including:
-
tests
Directory: Contains the source code files for integration tests written with Google Test. -
CMakeLists.txt
File: This file is used to configure and generate the project's build system using CMake. -
Other Source Code Files: In addition to test files, the project may include source code files that implement the server endpoints and other components necessary for integration testing.
To execute the integration tests, there are two different ways to run the tests:
-
Make sure you are in the DevOps repository.
-
Bring up all necessary containers by running the
test.yml
file. This file will start all containers required to run the integration tests.docker compose -f test.yml up --build
-
Once Docker has finished bringing everything up, all existing tests will be automatically executed.
- In the
devops
repository, execute the following command to acccess the test container:docker exec -it test bash
- Within the container, you can run the tests you're interested in. For example, if your tests have the following structure
TEST(suite_name, test_name)
:- change to the test directory:
cd test
- run a specific test using the Google Test filter:
./test --gtest_filter="suite_name.test_name"
- to run all test starting with a specific name, use the asterisk as a wildcard:
./test --gtest_filter="suite_name*"
These methods allow you to execute the integration tests automatically or manually, depending on your needs and preferences. The second method is useful when you only need to run specific tests within the project due to time constraints or other considerations.