4

我正在尝试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 ]

测试.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
4

1 回答 1

4

添加tests/HUniths-source-dirs. hs-source-dirs不递归搜索。

于 2013-04-15T19:23:27.590 回答