Conf42: Python 2021


Stop Writing Tests!

Zac Hatfield-Dodds
Researcher @ Australian National University

Zac Hatfield-Dodds's LinkedIn account

Under-tested financial code is a very bad idea - just ask Knight Capital how they lost $460 million in less than an hour. More often, bugs expose you to a little more risk or a little less value that you expected… but what can we do differently?

We often think of manual testing as slower and less effective than automated testing, but most test suites haven’t automated that much!

Computers can execute all our pre-defined tests very quickly - and this is definitely a good thing, especially for regression tests - but the tricky parts are still done by humans. We select test cases (inputs) and check that the corresponding outputs make sense; we write functions that “arrange, act, and assert” for our tests; and we decide - or script via CI systems - which tests to execute and when.

So lets explore some next-generation tools that we could use to automate these remaining parts of a testing workflow!

Property-based testing helps you to write more powerful tests by automating selection of test cases: instead of listing input-output pairs, you describe the kind of data you want and write a test that passes for all X…. We’ll see a live demo, and learn something about the Python builtins in the process!

Code Introspection can help write tests for you. Do you need to know any more than which code to test, and what properties should hold?

Adaptive Fuzzing take CI to its logical conclusion: instead of running a fixed set of tests on each push, they sit on a server and run tests full-time… fine-tuning themselves to find bugs in your project and pulling each new commit as it lands!

By the end of this talk, you’ll know what these three kinds of tools can do - and how to get started with automating the rest of your testing tomorrow.


Is it really automated testing when you still have to write all the tests? What if your tools:

  1. wrote test code for you (‘ghostwriting’)
  2. chose example inputs (property-based testing)
  3. decided which tests to run (adaptive fuzzing)

Now that’s automated - and it really does work!

Awesome tech events for

Priority access to all content

Community Discord

Exclusive promotions and giveaways