Looking for elegant mocking library to using with snitch #181
Replies: 1 comment
-
Hi there! I don't tend to use mocking frameworks in C++; contrary to Python, it's never easy and always requires a fair deal of boilerplate. It's the price to pay for static typing, I guess. I'm hopeful that simpler solutions will be possible once reflection gets voted into the C++ standard, but we'll need to wait for C++26 for that (at best). When I did use mocking, it was at work, and using GoogleMock (gmock) which ships with GoogleTest (gtest). Mostly because we use gtest at work; I've never tried any other mocking framework. But the experience using it was OK; the boilerplate was reasonable (i.e., I understand why it's needed and why we can't make it better at the moment). Perhaps others will have more interesting feedback though! |
Beta Was this translation helpful? Give feedback.
-
I'm currently using
Catch2
, but I'm attracted to the features/benefits ofsnitch
.I've struggled to find a good mocking library (I come from
pytest
environment) that works withCatch2
and one that is well supported. I need both C and C++ testing.I have successfully used
mockcpp
withCatch2
but I worry about one man projects and the last commit was 2022.What do snitch users and maintainers use or recommend to use with
snitch
(and presumably would also work withCatch2
)?My preference is something that can purely mock or fake functions, or use the original functions, in individual tests, and doesn't get in the way of the test runner assert mechanism.
i.e. individual tests in the same compilation unit can have different mocks or no mocks at all.
i.e. can use REQUIRE or ASSERT ...
I would be grateful for any suggestions :)
Beta Was this translation helpful? Give feedback.
All reactions