How to write readable tests

So often, our tests are much harder to understand than the rest of our code. This is a shame! Find out how to write tests that act as living documentation from which you can gain deeper understanding of your system.

Talk
13 Sep 2019 PyCon UK
 tests  readability

Have you ever found yourself scratching your head when reading an automated test? Even if we take pride in our application code, it’s all too easy for us to neglect readability in our tests.

But tests can be more than just a safety net that nobody reads unless they break. In this talk, I show you six principles for how to write Python tests that you will love, and keep coming back to.

Six Principles for Readable Tests

  • Profit from the work of others
  • Put naming to work
  • Show only what matters
  • Don’t repeat yourself
  • Arrange, act, assert
  • Aim high

Comments