Property-Based Testing - Examples of Properties from Business Applications

location_city Virtual schedule Oct 15th 03:30 - 04:15 PM place Online people 22 Interested

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 [1]:

  • 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!

[1] 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

Learning Outcome

How to use property-testing effectively in typical web applications

Target Audience

Tech Leaders and Engineers interested in TDD and Testing at large

schedule Submitted 10 months ago

Public Feedback

comment Suggest improvements to the Author