Loading…
CppCon 2018 has ended
View analytic
Wednesday, September 26 • 15:15 - 15:45
To Kill a Mocking Framework: Tools and Techniques for Testing Callbacks Using Standard C++

Sign up or log in to save this to your schedule and see who's attending!

Callbacks are a commonly used technique for delivering data and passing control from one component to another. Their many uses include handling asynchronous events, providing customizations, and (with polymorphic lambdas) enable functional-style programming in C++. Testing components which invoke polymorphic callbacks can be a challenge, and this leads some developers to either avoid testing altogether, or to rely on mocking frameworks such as Google Mock.

Mocking frameworks sometimes rely on a Domain Specific Language or other syntax for expressing expectations on the mocked objects. My intention for this talk is to outline some ways in which standard C++ features and idioms can be used to test components with callbacks, as an alternative to such frameworks. In particular, I'll show how employing core features - lambdas, std::function, and RAII - allows us to build mocks which clearly express the desired behavior from the code under test, whilst being expressive and hard to misuse.

Speakers
avatar for Alastair Rankine

Alastair Rankine

VP, Automated Market Making, Morgan Stanley
Alastair is a developer who has been in the finance industry for the last 10 years, writing low latency trading software. He first discovered C++ in the early 90s, and has been developing software with it professionaly ever since. He likes solid abstractions, efficient processes... Read More →


Wednesday September 26, 2018 15:15 - 15:45
Keystone (404)

Attendees (159)