I have problems setting up unit-tests with Test-Framework and HUnit.
I have the following imports in my testfile:
import Test.Framework
import Test.Framework.Providers.QuickCheck2
import Test.Framework.Providers.HUnit
When I try to load the file in ghci
I get the error-message:
test/MainTestSuite.hs:3:8:
Could not find module ‘Test.Framework.Providers.HUnit’
Perhaps you meant
Test.Framework.Providers.API (from test-framework-0.8.1.1)
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Only loading Test.Framework
and Test.Framework.Providers.QuickCheck2
works and can run the tests. According to cabal
test-framework-hunit
is installed:
$ cabal install test-framework-hunit
Resolving dependencies...
All the requested packages are already installed:
test-framework-hunit-0.3.0.1
Use --reinstall if you want to reinstall anyway.
Notice: installing into a sandbox located at
/home/XXX/projects/my_project/.cabal-sandbox
Also test-framework-hunit
is listed as a dependency in the my_project.cabal
-file:
test-suite tests
main-is:
MainTestSuite.hs
type:
exitcode-stdio-1.0
hs-source-dirs:
test,
src
build-depends:
base,
HUnit,
QuickCheck,
test-framework,
test-framework-hunit,
test-framework-quickcheck2,
containers >=0.5 && <0.6
default-language:
Haskell2010
What am I doing wrong? If that matters: I'm installing everything into a cabal-sandbox
.
Sandboxed packages are visible to cabal
but not to ghc
or ghci
without additional flags. But you can alter your environment in general for a process by executing it with cabal exec myCmd
-- and even better, for ghci
in particular, cabal repl
is a more full-featured solution that opens "stuff you want" in a variety of situations, both with and without sandboxes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.