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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free