3

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

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工作并且可以运行测试。根据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

在-file 中也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

我究竟做错了什么?如果这很重要:我正在将所有内容安装到cabal-sandbox.

4

1 回答 1

0

沙盒包对附加标志可见cabal但不可见ghcghci没有附加标志。但是,您可以通过执行进程来改变您的环境,cabal exec myCmd甚至更好,ghci特别是,cabal repl它是一个功能更全面的解决方案,可以在各种情况下打开“你想要的东西”,无论是否有沙箱.

于 2016-03-13T06:58:31.207 回答