Getting started with testing Haskell in 2024

I have (finally) reached a point where I need to write tests for a small Haskell program I have written, which is being used in anger.

Are there any recommendations on what libraries / tools to use, if you are starting from nothing, today?

I will go searching and looking, but sometimes a(n opinionated) recommendation is a useful starting point.

5 Likes

The Stack project uses hspec and QuickCheck, but that may reflect its history. tasty says it is ‘modern’ and it also has ‘providers’ for Hspec and QuickCheck tests.

1 Like

doctest is handy. The tasty ecosystem is good. My shelltestrunner might be useful for cli tests. If you get into property testing later, try the variants like hedgehog or smallcheck, not just quickcheck.

2 Likes

I use and love hspec. Well documented, integration with QuickCheck/SmallCheck/HUnit if needed, good documentation, batteries included.

3 Likes

My go-to toolkit is tasty as the harness, tasty-hunit for unit tests, tasty-golden for golden tests, and tasty-quickcheck for property-testing.

1 Like

I maintain a list but it still needs fleshing out. I like the tasty testing universe and hedgehog for property testing (because of automatic shrinking and gens-as-values).