Generating Tests With Properties
at SSDUG on Thursday, July 13, 2023
This talk has been floating around in my head for the better part of seven years. I tried some live coding, and while I didn’t succeed in doing what I wanted to with it I think it still illustrated the ideas well. You can follow along with the example code if you’d like. It’s blessedly short compared to the other talks from SSDUG I’ve posted here.
This testing technique holds a special place for me, as it’s helped some of the most lasting, impactful things I’ve accomplished in my career. I also love it because:
- it finds problems I never would have gone looking for
- it forces me to really think about what the thing I’m trying to test actually does, rather than just about what some scenarios for success or failure look like
- it helps me to understand and define the boundaries of the thing I’m trying to test
- it empathizes with me by presenting the simplest way it can fail my test
It’s also given me a new gripe about JavaScript’s notion of equality: while officially -0 === +0
, this apparently does not hold true for deep comparisons made by some testing libraries.
Anyway, I hope to put together a blog post on the topic soon.