← Lessons

quiz vs the machine

Platinum1850

Concurrency

The Property Based Concurrency Test

Generate random operation sequences and check a concurrency property like linearizability.

5 min read · advanced · beat Platinum to climb

From examples to properties

Instead of writing one fixed scenario, a property based test generates random sequences of concurrent operations and checks that a general property always holds.

What it checks and how

The framework runs the generated operations across threads, records the resulting history, and verifies a property such as linearizability:

  • generate parallel operation sequences with random arguments
  • execute them under varied or controlled scheduling
  • check the recorded history against a sequential model
  • on failure, shrink the sequence to a minimal failing case

Shrinking is what makes the result usable, reducing a noisy history to the smallest interleaving that still fails.

Strength and limits

Property based testing covers a huge space of scenarios automatically and produces tiny counterexamples, but like all testing it samples; passing many cases raises confidence without proving correctness.

Key idea

A property based concurrency test generates random operation histories and checks them against a sequential model, then shrinks any failure to a minimal interleaving you can actually debug.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a property based concurrency test verify?

2. Why is shrinking important in these tests?