[英]Problems with Test-Framework and HUnit
I have problems setting up unit-tests with Test-Framework and HUnit. 我在使用Test-Framework和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: 当我尝试在ghci
加载文件时,出现错误消息:
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. 仅加载Test.Framework
和Test.Framework.Providers.QuickCheck2
可以并且可以运行测试。 According to cabal
test-framework-hunit
is installed: 根据cabal
test-framework-hunit
的安装:
$ 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: 在my_project.cabal
-file中, test-framework-hunit
也作为依赖项列出:
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
. 如果那很重要:我cabal-sandbox
所有东西都安装到cabal-sandbox
。
Sandboxed packages are visible to cabal
but not to ghc
or ghci
without additional flags. 沙盒包对于cabal
是可见的,但是对ghc
或ghci
是可见的,没有附加标志。 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. 但是您可以通过使用cabal exec myCmd
执行环境来总体上更改进程的环境-甚至更好,特别是对于ghci
, cabal repl
是功能更全面的解决方案,可以在各种情况下打开“所需的东西” ,无论有无沙盒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.