Testing Legacy C++ Code effectively with Approval Tests

Clare Macrae

one day workshop
beginner
intermediate
10:30-19:15, Thursday, 1st July 2021

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 workshop will enable you to become productive and work safely, quickly.

In this hands-on workshop, you will learn not just how to use Approval Tests to start testing legacy code, but how to create effective, maintainable, expressive tests, even on large systems.



Prerequisites

  • Some prior experience of programming in C++
  • Zoom with a microphone and camera
  • AnyDesk software installed, to log in to a shared virtual machine on Amazon's infrastructure (subject to change)

Syllabus/Topics:

  • Testing functional/pure code
  • Testing with Approval Tests
  • Testing non-functional/non-pure code
  • Testing code in hard-to-test scenarios (of time)

Attendees will learn how to:

  • Break the cycle of can't refactor/no tests
  • Break up an existing application to add tests
  • Approval Tests
  • Write first Approval Test
    • Chose suitable tools for visualising program output (pick effective Reporter)
    • Deal with non-stable output
    • Use Approval Tests effectively, for highly maintainable tests

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.