Search⌘ K
AI Features

Introduction

Explore property-based testing in Elixir using ExUnit to generate random test inputs. Understand how this approach reveals edge cases, increases code confidence, and helps refine your code's expected properties for better implementation.

Even the best-designed unit tests are limited to the number of inputs we can throw at our code. In this chapter, we’re going to learn about a new testing technique called property-based testing.

Introduction

Property-based testing introduces randomness into our tests by generating random inputs to feed to our code. This increases our confidence in the code and can lead to discovering pesky bugs by generating weird edge cases. Property-based testing also forces us to think differently about the accepted inputs and the properties of our code, often helping with the design and implementation.

Property-Based Testing

A while ago, an issue was ...