Skip to content

Commit 3bb7162

Browse files
committed
refactor: reorganize test structure and update CMake configuration for better clarity
1 parent e34bb22 commit 3bb7162

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed

tests/CMakeLists.txt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,24 @@
1-
include(FetchContent)
2-
3-
FetchContent_Declare(
4-
googletest
5-
GIT_REPOSITORY https://github.com/google/googletest.git
6-
GIT_TAG v1.15.2
7-
)
8-
9-
# For Windows: Prevent overriding the parent project's compiler/linker settings
10-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
11-
FetchContent_MakeAvailable(googletest)
12-
131
enable_testing()
142

153
add_executable(
164
${PROJECT_NAME}_tests
175
main_test.cpp
186
unit_tests.cpp
197
test_functions.cpp
20-
test_functions.hpp
21-
ProjectIntegrationTestSuite.cpp
22-
ProjectIntegrationTestSuite.hpp
8+
test_suites/ProjectIntegrationTestSuite.cpp
239
)
2410

2511
target_link_libraries(
26-
${PROJECT_NAME}_tests # link used libraries from lib directory
12+
${PROJECT_NAME}_tests
2713
ui
2814
mylib
2915
GTest::gtest_main
3016
)
3117

32-
if (NOT CMAKE_BUILD_TYPE)
33-
set(CMAKE_BUILD_TYPE Debug) # Tests should be built with Debug
34-
endif ()
35-
3618
message(STATUS "Tests build type: ${CMAKE_BUILD_TYPE}")
3719

3820
target_include_directories(${PROJECT_NAME}_tests PUBLIC ${PROJECT_SOURCE_DIR})
3921

4022
include(GoogleTest)
4123

42-
gtest_discover_tests(${PROJECT_NAME}_tests)
24+
gtest_discover_tests(${PROJECT_NAME}_tests)

tests/main_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
#include <filesystem>
12
#include <sstream>
23

34
#include <gtest/gtest.h>
4-
#include "ProjectIntegrationTestSuite.hpp"
5-
#include "test_functions.hpp"
65
#include "lib/ui/ui_functions.hpp" // include your library here
6+
#include "test_functions.hpp"
7+
#include "test_suites/ProjectIntegrationTestSuite.hpp"
78

89
TEST_F(ProjectIntegrationTestSuite, InitTest) {
910
ASSERT_TRUE(std::filesystem::is_directory(kTemporaryDirectoryName));

tests/ProjectIntegrationTestSuite.cpp renamed to tests/test_suites/ProjectIntegrationTestSuite.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <filesystem>
2+
13
#include "ProjectIntegrationTestSuite.hpp"
24

35
void ProjectIntegrationTestSuite::SetUp() {

tests/ProjectIntegrationTestSuite.hpp renamed to tests/test_suites/ProjectIntegrationTestSuite.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef TEMPORARYDIRECTORYTESTSUITE_HPP_
22
#define TEMPORARYDIRECTORYTESTSUITE_HPP_
33

4-
#include <filesystem>
54
#include <string>
65

76
#include <gtest/gtest.h>
@@ -14,4 +13,4 @@ struct ProjectIntegrationTestSuite : public testing::Test { // special test stru
1413
void TearDown() override; // method that is called at the end of every test
1514
};
1615

17-
#endif //TEMPORARYDIRECTORYTESTSUITE_HPP_
16+
#endif // TEMPORARYDIRECTORYTESTSUITE_HPP_

0 commit comments

Comments
 (0)