2013-06-25 49 views
4

當您在耶索德有支架的網站,它把測試分爲單獨的目錄是這樣的:進口(進口模塊從耶索德測試)

YourProj/ 
YourProj/SomeModule.hs 
YourProj/Handlers/FooHandler.hs 
... 
YourProj/tests/main.hs 
YourProj/tests/FooTests.hs 

所以,現在我想火ghci並從YourProj/tests/main.hsYourProj/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. 

所以,雖然我成功加入子目錄,我還有因爲在小集團文件build-depends參數測試套件的不同陰謀配置的問題。

我將如何啓動cabal-dev ghci並從Yesod的測試中導入一些代碼?

+0

好吧,我去手動添加從測試套件到主構建依賴部分的構建依賴線,現在它抱怨「不在範圍內:'$'」。 –

+1

你只需要導入'Prelude','cabal'文件默認打開'NoImplicitPrelude'。 –

+0

@MichaelSnoyman謝謝,現在一切正常!我會在這裏寫一個答案。 –

回答

4

好了,答案是這樣的:

  1. 從測試套件的build-depends添加您的小集團文件中所有缺少的模塊插入頂部您的應用程序的build-depends
  2. 應用程序的根目錄中運行cabal-dev ghci:set -itests

然後,您應該能夠做到像:load tests/EntriesTest.hs罰款。