DEV Community

Kimmo Sääskilahti
Kimmo Sääskilahti

Posted on

2

Introduction to property-based testing

Property-based testing is a testing paradigm supporting regular example-based unit tests. In the Pragmatic Programmer book, the authors recommend to use property-based testing for verifying assumptions about their code. It forces you to think about the actual preconditions, postconditions and invariants of your code instead of implicitly coming up with such rules through hard-coded examples.

I recently gave a presentation at work about property-based testing. You can find the slides at ksaaskil.github.io/introduction-to-property-based-testing/ and the accompanying code in github.com/ksaaskil/introduction-to-property-based-testing. The presentation also contains some material about testing stateful systems, an intriguing but complex topic.

Most of the contents in the presentation come from the Property-Based Testing with PropEr, Erlang, and Elixir book. It's an awesome book and I highly recommend it! Don't be put off if you don't know Erlang or Elixir: the code samples are very readable (well at least the Elixir ones are) and you may learn a beautiful new language. I know I love Elixir now!

Thanks for reading, as always I appreciate any feedback.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay