我试图让cabal test
运行我的HUnit测试,但没有多大运气。问题在于它找不到我的测试模块之一,该如何解决?cabal configure --enable-tests && cabal build && cabal test
失败并显示
tests/HUnit/Test.hs:4:18:
Could not find module `AmazonTest'
/ tests / HUnit
AmazonTest.hs
module AmazonTest where
import Test.HUnit
import Lib.Amazon
tests = TestList [ "test sayHello" ~: "Hell!" ~=? sayHello ]
测试
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
最佳答案
将tests/HUnit
添加到hs-source-dirs
。 hs-source-dirs
不会递归搜索。