I am trying to figure out how to get started with unit testing using stack. Using the new-template project template generates a file test/Spec.hs that outputs a string. So in this Spec.hs file, I should add some HUnit code or Hspec code?
It’s HSpec code, not HUnit. I don’t have many tests, but you can see an example here: https://github.com/iustin/corydalis/blob/master/test/PicsSpec.hs. More examples are in the Handler subdirectory, but that’s Yesod-specific testing.
Thanks for your example, Iustin. This is helpful for me. I will read about the differences of HSpec and HUnit. For now, reading about automatic spec discovery was helpful for me as well, to understand how to organize test modules: https://hspec.github.io/hspec-discover.html
Anyway, I have my first unit test up and running now. Thanks again.