当您在yesod中创建一个脚手架网站时,它会将测试放入单独的目录中,如下所示:
YourProj/
YourProj/SomeModule.hs
YourProj/Handlers/FooHandler.hs
...
YourProj/tests/main.hs
YourProj/tests/FooTests.hs
所以,现在我要解雇ghci并从YourProj/tests/main.hs
或YourProj/tests/FooTests.hs
导入一些代码来玩。我该怎么做?我试过了:
cabal-dev ghci
> :set -itests
> :load tests/TestImport.hs
tests/TestImport.hs:15:8:
Could not find module `Control.Monad.IO.Class'
It is a member of the hidden package `transformers-0.3.0.0'.
Perhaps you need to add `transformers' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
所以,当我成功添加子目录时,由于测试套件的cabal文件中build-depends
参数的cabal配置不同,我仍然遇到问题。
我如何启动cabal-dev ghci并从Yesod的测试中导入一些代码?
答案 0 :(得分:4)
好的,答案是这样的:
build-depends
的cabal文件中所有缺少的模块添加到应用程序的build-depends
之上。cabal-dev ghci
并执行:set -itests
然后你应该可以做:load tests/EntriesTest.hs
罚款。