Reputation:
How do I specify test suites in HSpec? I'm going to have multiple *.hs
test files for each of my modules and I want to just run stack test
and for all of the tests to run. How do I set that up?
I tried to list the test modules like this in my cabal file but it doesn't work:
test-suite foo-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
, Mod1Spec.hs
build-depends: base
, containers >= 0.5.6.2
, hqfl
, hspec >= 2.2.3
, hspec >= 2.2.3
, mtl >= 2.2.1
, pipes >= 4.1.8
, random >= 1.1
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
Upvotes: 1
Views: 1599
Reputation: 52059
Here is some docs on hspec testing:
http://hspec.github.io/hspec-discover.html
If your main spec module contains just the lines:
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
hspec-discover
will scan the directory tree for spec tests.
Also - here is a small hspec example:
https://github.com/hspec/hspec-example
Upvotes: 5