Skip to content

Commit

Permalink
ci(pipeline): fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealPad committed Feb 28, 2024
1 parent 8846d11 commit 66b18b0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
run: make

- name: Test
run: ./test_creditCardValidator
run: ./unit_test
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,31 @@ project(Calculator VERSION 1.0
LANGUAGES CXX)

SET(NAME "calculator")
SET(TEST_NAME "unit_test")

set(CMAKE_CXX_STANDARD 17)

set(SRC
main.cpp
)
)

add_executable(${NAME} ${SRC})

set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})

add_compile_options(-fPIC)

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
)
FetchContent_MakeAvailable(googletest)

add_executable(${TEST_NAME} tests/test.cpp)
target_link_libraries(${TEST_NAME} PUBLIC gtest_main)

include(CTest)
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})
12 changes: 12 additions & 0 deletions tests/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <gtest/gtest.h>

TEST(BasicUnitTest, ValidEquality)
{
EXPECT_EQ(1 == 1, true);
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 66b18b0

Please sign in to comment.