KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1.05k stars 246 forks source link

[GeoMechanicsApplication] First experiment with GMock #12841

Closed rfaasse closed 1 week ago

rfaasse commented 2 weeks ago

📝 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:

  1. If we have to override functions (i.e. base class has purely virtual functions), this can be done easily with the MOCK_METHOD macro
  2. Functions created with these macro can be checked using the EXPECT_CALL macro. You can set the expectation for how many times a function is called (for example EXPECT_CALL(*converging_strategy, Predict()).Times(1)), you can also control what it will output (for example EXPECT_CALL(*converging_strategy, GetNumberOfIterations()).WillOnce(testing::Return(4)); or ON_CALL(*this, GetNumberOfIterations()).WillByDefault(testing::Return(4));)