See https://github.com/AlexandreBrown/GTestSetup to setup GTest by downloading the GitHub repo instead of downloading it via CMake.
Depending on how you want to run your tests there might be some setup required.
- No additional setup required.
- To run the all the tests inside
MyClassTest
you can use the run button at the test fixture or test name- You can also right click a folder with tests and run all the tests or you can run individual tests using the green run button
- You can also run tests from the bottom pane that opens up after runnign tests initially
- Using the IDE to run tests might provide better feedback than other alternatives (subjective)
- Create build directory from the root of
GTestSetup
folder (eg:GTestSetup/build
).
mkdir build
cd build
- Try to cmake and make to ensure your project is well setup
- In a terminal at
GTestSetup/build
location, do the following commands:cmake ..
make
- If no error occured then everything should be setup correctly.
- Run unit tests
- Run the following inside of the
GTestSetup/build
folder :make && make test
or simplymake test
if you already didmake
and no files changed since.
- Delete
/build
folder and recreate/populate it usingmkdir build
+cmake ..
+make
- CLion : File->Invalidate cache & restart
- Try to right click your test class from the file explorer (inside CLion) and click "Run all in YourClassTest.cpp"
- If it doesn't work try deleting the
/build
folder and recreating it and repopulating it using steps describe in Global fixes to try - If it doesn't work try running your tests using
make test
from/build
folder
- Change the include from #include <gtest/gtest.h> to #include "gtest/gtest.h"
- If the error still occurs try deleting
/build
and recreating/populating it using steps describe in Global fixes to try
- Try deleting
/build
and recreating/populating it using steps describe in Global fixes to try
- Try re-running the test, maybe it was ran with outdated code or try
make && make test
from/build
- Try File->Invalidate cache & restart