Quickly and Effectively Testing Legacy C++ Code with Approval Tests

Clare Macrae

75 minute presentation

You've inherited some legacy code: it's valuable, but it doesn't have tests, and it wasn't designed to be testable, so you need to start refactoring. But you can't refactor safely until the code has tests, and you can't add tests without refactoring! How can you ever break out of this loop?

Whether Legacy code for you means "old code", "code without tests", or "code you wish to redesign for new features or unit-tests", this talk will enable you to become productive and work safely, quickly.

The simplicity, convenience, ease-of-use, power and flexibility of Llewellyn Falco's "Approval Tests" approach has long been proven in a dozen programming languages. And now all this is now available to C++ developers too!

Clare will present a small but surprisingly effective C++11 library for applying "Approval Tests" to cross-platform C++ code - for both legacy and green-field systems, and with a range of testing frameworks.

She will demonstrate its use in some real-world situations, including how to quickly lock down the behaviour of legacy code. She will show how to quickly achieve good test coverage, even for very large sets of inputs.

She will also show recent work applying Approval Tests to testing Graphical User Interfaces

Finally, she will describe some powerful techniques used in the implementation, that are useful beyond the field

Attendees will discover some quick, practical techniques to use for common challenges, such as testing GUI systems, and outputs containing dates and times, that can be applied very easily using Approval Tests.


Clare is also running a full day workshop on Legacy Code and Approval Tests, with Llewelyn Falco, just after the main conference.

legacy code
cross platform

Clare Macrae

Clare is an independent consultant, helping teams work sustainably and efficiently to test and refactor legacy and hard-to-test code.

She has worked in software development for over 30 years, and in C++ and Qt for 20 years, and is now branching out to other languages.

Since 2017, Clare has used her spare time to work remotely with Llewellyn Falco onĀ ApprovalTests.cpp, to radically simplify testing of legacy code. She has enjoyed this so much that in 2019 she set up Clare Macrae Consulting Ltd, to focus even more on helping others work with legacy code.

Before this, Clare was a Principal Scientific Software Engineer at Cambridge Crystallographic Data Centre. She is the original author of their popular C++ and Qt-based 3D crystal structure visualisation programĀ Mercury.