4 ms·
I thinks mocks are better in C++ than in dynamic languages. In C++ you need to expose a public interface for the customization point so it can be mocked. Mocks
by planede 3y ago
I thinks mocks are better in C++ than in dynamic languages. In C++ you need to expose a public interface for the customization point so it can be mocked. Mocks therefore test a public interface and not implementation details. Granted, if that "public interface" is not used outside of tests then it's not much different, but I think it adds the correct amount of friction for mocking.
In dynamic languages you can mock anything, even parts that are not designed to be customizable. This indeed has the effect of calcifying implementation details, as mocks don't test a public interface. I think it's harder in this environment to stay disciplined and use mocking in moderation, as the friction to only mock public interfaces is not there.
I definitely saw this in C++ vs Python mocking, mocking tends to be way overused in Python testing.