Test-Framework和HUnit的问题

时间:2015-03-29 11:53:56

标签: unit-testing haskell cabal hunit

我在使用Test-Framework和HUnit设置单元测试时遇到问题 我的testfile中有以下导入:

import Test.Framework
import Test.Framework.Providers.QuickCheck2
import Test.Framework.Providers.HUnit

当我尝试在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.

仅加载Test.FrameworkTest.Framework.Providers.QuickCheck2,并且可以运行测试。根据{{​​1}} 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 test-framework-hunit - 文件中列为依赖项:

my_project.cabal

我做错了什么?如果重要:我将所有内容安装到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

1 个答案:

答案 0 :(得分:0)

沙箱包对cabal可见,但在没有其他标记的情况下不会显示给ghcghci。但是,您可以通过cabal exec myCmd执行一般流程来改变您的环境 - 更好的是,对于ghcicabal repl是一个功能更全面的解决方案,可以打开& #34;你想要的东西&#34;在各种情况下,无论是否有沙箱。