This is a repo to help you start your journey about testing your C++ code with GoogleTest and CMake with >= C++14.
This repo depends on GoogleTest.
.
- - src
- - - - MyProject
- - - - - - src
- - - - - - - - MyClass.cpp
- - - - - - - - MyClass.hpp
- - - - - - CMakeLists.txt <- define library MyLibrary
- - - - Main.cpp
- - - - CMakeLists.txt <- use MyLibrary & define main executable
- - tests
- - - - UnitTests
- - - - - - MyClassTest.cpp
- - - - CMakeLists.txt <- use MyLibrary & define test executable
git clone --recurse-submodules https://github.com/gyoce/Tests_CPP.git
mkdir build
cd build
cmake ..
cmake --build .
- Open the directory in Visual Studio
- Press CTRL + SHIFT + B
After building run the main executable with :
./[PATH_TO]/CPP.exe
You can run test with the command (inside the build directory) :
ctest
- Open the directory in Visual Studio
- Select Startup Item (CPP.exe for main & CPPTests.exe for tests)
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build .
ctest