Tests that (Almost) Write Themselves

Hints for Golden Master Testing in Python

Stefan Baerisch

Best Practice Test Libraries (pytest/nose/...) Testing Tooling

See in schedule Download/View Slides

What do we do when the only test requirements we have are "the new system should have the exact same results as the old system"? Golden Master Testing may help.
The idea behind golden master testing, also called characterization testing, is quite simple: We don't write test cases that specify what the expected result is. Instead, we take the output from a prior, working version of a program (the golden master) and compare it to the result of the current version. If there is a difference between the output of the current system and the golden master, we may have found a bug.

If implemented right, Golden Master testing can be very useful to test legacy systems or data processing programs with complex input and outputs. Golden Master Testing is also a good addition to our regression testing processes.

In practice, implementing Golden Master testing is not quite that easy. Just checking if the outputs are equal will often not work: If the output includes times and dates or random elements, a simple comparison will not be enough. Luckily for use, with Python, we have the perfect tool to process all kinds of outputs and only look at the parts of the output that are important for the outcome of the test.

In this talk, we will look at best practices for Golden Master Testing with Python. We will see techniques to identify and quantify the relevant differences between our golden master and the current output.

Type: Talk (30 mins); Python level: Beginner; Domain level: Beginner


Stefan Baerisch

Stefan Baerisch Software Consulting

I started working with Python 2.5 around 2006 to build what might a called a micro-service backend for our company's search backend. In continued to use Python when I did Ph.D. research in automated testing, and I have always been happy with the boost in productivity that Python gave me.

Since then, I have switched roles multiple times, but I have continued to use Python. Sometimes as part of a customer project, sometimes to automate tedious tasks, and sometimes just for fun.
Besides fun and daily work, my primary interest is in text processing and machine learning on texts. I also like test automation and GUI programming.
Since 2020, I work as a freelancer, with Python and other interesting tools.