I'm trying to figure it out Google Test framework + CLion.
I unpacked the archive into ~/Documents/Libraries/googletest-main/
. Installed it, so that includes and libs are in /usr/local/include/
and /usr/local/lib/
, correspondingly.
Then, created a project in CLion with two files:
CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(TestProject)
set(CMAKE_CXX_STANDARD 14)
add_executable(TestProject test.cpp)
target_link_libraries(TestProject gtest gtest_main)
test.cpp
#include "gtest/gtest.h"
TEST(BasicTests, testName) {
EXPECT_EQ(1, 2);
}
TEST(BasicTests, testName2) {
ASSERT_EQ(2, 2);
}
TEST(BasicTests, testName3) {
ASSERT_EQ(3, 3);
}
TEST(BasicTests, testName4) {
ASSERT_EQ(4, 4);
}
Now, as a part of the CLion interface, I can run tests, but independently. From the framework documentation and tutorials, I know that I can not implement main()
, but use the function implemented in gtest_main.cc
(for me, the path is ~/Documents/Libraries/googletest-main/googletest/scr/gtest_main.cc
).
What needs to be done to run all the tests at once? (Often, in tutorials, the framework files lie inside the project folder, so the function RUN_ALL_TEST() can be run.)