-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GeoMechanicsApplication] First experiment with GMock #12841
Conversation
@@ -25,7 +25,7 @@ macro(kratos_add_gtests) | |||
add_executable("${KRATOS_ADD_GTEST_TARGET}Test" ${KRATOS_ADD_GTEST_SOURCES} ${KRATOS_GTEST_MAIN_SOURCE}) | |||
target_link_libraries("${KRATOS_ADD_GTEST_TARGET}Test" ${KRATOS_ADD_GTEST_TARGET} KratosCoreTestUtilities "${TESTING_MPI_UTILITIES}" GTest::gmock_main) | |||
set_target_properties("${KRATOS_ADD_GTEST_TARGET}Test" PROPERTIES COMPILE_DEFINITIONS "KRATOS_TEST_CORE=IMPORT,API") | |||
|
|||
target_compile_definitions("${KRATOS_ADD_GTEST_TARGET}Test" PUBLIC GTEST_LINKED_AS_SHARED_LIBRARY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roigcarlo It seems we need to set this compile definition since we're using GTest as a shared library (see e.g. https://stackoverflow.com/questions/46025439/unresolved-external-symbol-error-with-google-mock-and-vcpkg), otherwise I get linking errors when I try to use GMock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, no problem 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How nice that you have cleaned this up by using GMock. I have no comments, so please feel free to merge.
…dized GMock functionality for one set of unit tests (#12841)
📝 Description
This PR replaces manually created functions for two Mock/Stub/Spy classes with the MOCK_METHOD macro implemented in GMock. This has a couple of advantages:
EXPECT_CALL(*converging_strategy, Predict()).Times(1)
), you can also control what it will output (for exampleEXPECT_CALL(*converging_strategy, GetNumberOfIterations()).WillOnce(testing::Return(4));
orON_CALL(*this, GetNumberOfIterations()).WillByDefault(testing::Return(4));
)