Property-Based Testing - Examples of Properties from Business Applications
I got excited about property-based testing after hearing John Hughes talk at Functional Conf 2016. I tried it that year with QuickCheck, but failed miserably (it almost derailed the entire project delivery). I cribbed about it in my talk at Functional Conf 2017. In 2018, Srihari's talk got me excited again. This time, I tried with Hedgehog, and got it to work!
This talk is about this journey and its learnings. We'll talk about how Hedgehog was used to test :
- A Postgres backed task/job queue
- A small Wai/Servant based webapp
And no, we will not talk about the most common (and completely useless) example of reversing a list!
 Both of these are part of an open-sourced task/job queue library.
Outline/Structure of the Case Study
- Understanding property-based testing of pure code through real-world examples
- Problems faced while testing stateful code (most commonly where state is stored in a DB)
- Approaches used by various libraries for testing stateful code
- Walk-through of how property tests were used to ensure correctness of a Postgres-backed job/task queue
- Walk-through of how property tests were used to test a small DB-backed webapp
How to use property-testing effectively in typical web applications
Tech Leaders and Engineers interested in TDD and Testing at large