“Quickly Testing Qt Desktop Applications with Approval Tests”

  by Clare Macrae

Abstract

You’ve inherited some Qt GUI 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?

The talk will review the challenges and potential sources of error that are specific to code that uses the Qt cross-platform graphical user interface library, and then describe how to guard against them.

There are many options for unit-testing Qt code, including Qt Test, Google Test and Catch. As well as covering those, and general principles for applying them, I will present a small but surprisingly effective C++11 library for applying “Approval Tests” to cross-platform Qt code.

Finally, the talk will briefly cover some other tools that can aid with inspecting and maintaining Qt code, which can in turn improve testability.

Attendees will discover some quick, practical techniques to help write unit tests and integration tests for Qt code.

About the speaker

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.