cabal测试没有找到模块

时间:2013-04-15 18:47:49

标签: haskell cabal

我正试图让cabal test运行我的HUnit测试,没有太多运气。问题是它无法找到我的测试模块之一 - 我该如何解决这个问题?

cabal configure --enable-tests && cabal build && cabal test失败

tests/HUnit/Test.hs:4:18:
    Could not find module `AmazonTest'

/测试/ HUnit

AmazonTest.hs

module AmazonTest where

import Test.HUnit
import Lib.Amazon

tests = TestList [ "test sayHello" ~: "Hell!" ~=? sayHello ]

Test.hs

module Main where

import Test.HUnit
import qualified AmazonTest as Amazon

main = runTestTT Amazon.tests

\ LIB \ Amazon.hs

module Lib.Amazon where

sayHello :: String
sayHello = "Hello!"

测试我的.cabal文件的一部分

test-suite test
    type:              exitcode-stdio-1.0
    main-is:           tests/HUnit/Test.hs
    hs-source-dirs:    .
    ghc-options:       -Wall

    build-depends: base
                 , myapp
                 , yesod-test >= 0.3 && < 0.4
                 , yesod-default
                 , yesod-core
                 , persistent
                 , persistent-postgresql
                 , resourcet
                 , monad-logger
                 , HUnit
                 , text

1 个答案:

答案 0 :(得分:4)

tests/HUnit添加到hs-source-dirs。不会递归搜索hs-source-dirs