I have the following architecture :
backend
├── Chat.hs
├── Main.hs
└── Message.hs
test
├── backendSpec
│ └── MessageSpec.hs
└── Spec.hs
My .cabal file contains the following
test-suite spec
build-depends: base, hspec == 2.*,
snap >= 0.14.0.6,
containers,
aeson,
text,
transformers,
stm,
snap-core,
snap-server,
socket-io,
engine-io-snap,
snap-cors,
bytestring
hs-source-dirs: test
main-is: Spec.hs
Type: exitcode-stdio-1.0
but when I do
stack test
HSpec cannot find my test int MessageSpec.hs.
Finished in 0.0002 seconds 0 examples, 0 failures
Spec.hs is the correct input : {-# OPTIONS_GHC -F -pgmF hspec-discover #-}
and my MessageSpec module is exposing : module MessageSpec (main, spec).
Could you help me find a way to make my stack project doing all my tests.
Thank you,
Your path to your spec must follow the module name convention.
backendSpec.MessageSpecis not a valid module name, since it starts with a lowercase letter.Furthermore, the module name of your spec should only differ by the additional suffix
Specfrom your original module. Your modules inbackendSpecwouldn't follow this:So to fix this, make sure that all directories in your
testdirectory start with an uppercase letter. But even better, make sure that the test directory has the same structure as yoursrcdirectory, as this will result in better module names during your tests:vs
(The relevant code for this behaviour can be found in
hspec/Run.hsofhspec-discover)