Property Based Testing with Hypothesis: Stronger Tests, Less Work

Shai Geva Shai Geva
Language: English
video in English
The presentation was given on 2022.06.28 at PyCon Israel 2022 - Conference.

Property based tests are a pragmatic way to write better tests with less work.

In this talk, we’ll introduce property based tests and show how they can help you in real-world use-cases.

Automated tests are great. But they’re not free - we all want tests that are good at protecting us from bugs - but to get that, we need to put a lot of work into them.

Property based testing is a technique that saves us a lot of this work. It uses the computer to generate hundreds, or even thousands of test cases - so we don’t have to. This helps us find bugs sooner and more easily, and have more confidence in our code.

This session will point you in the right direction to start using property based tests in your work.

We will explore the technique through Python’s excellent Hypothesis framework and go over the fundamental concepts, basic usage and tooling.

We’ll also get a feeling for the power and variety of real-world use cases, by creating a test that explores a CRUD web application, finding bugs in edge cases we didn’t know.

We’ll finish with pointers and resources to help you get started.