簡體   English   中英

找不到模塊“ Test.Hspec.Discover”

[英]Could not find module ‘Test.Hspec.Discover’

我是菜鳥

我試圖將單個Hspec / QuickCheck測試從一個較大的項目中復制並粘貼到我自己的項目中,以便進行調整並查看其行為。

我有一個像這樣的結構:

myproject/test/Spec.hs
myproject/test/mytest.hs

從另一個項目復制我的Spec.hs只是:

{-# OPTIONS_GHC -F -pgmF hspec-discover #-}

這與文檔中顯示的示例完全相同: http : //hspec.github.io/hspec-discover.html

另外,我在package.yml

tests:
  myproject-test:
    main:                Spec.hs
    source-dirs:         test
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - myproject
    - QuickCheck
    - hspec-megaparsec
    - hspec-discover

當我運行stack test ,出現以下錯誤:

$ stack test
hspec-discover  > configure
hspec-discover  > Configuring hspec-discover-2.6.1...
hspec-discover  > build
hspec-discover  > Preprocessing library for hspec-discover-2.6.1..
hspec-discover  > Building library for hspec-discover-2.6.1..
hspec-discover  > [1 of 4] Compiling Paths_hspec_discover
hspec-discover  > [2 of 4] Compiling Test.Hspec.Discover.Config
hspec-discover  > [3 of 4] Compiling Test.Hspec.Discover.Sort
hspec-discover  > [4 of 4] Compiling Test.Hspec.Discover.Run
hspec-discover  > Preprocessing executable 'hspec-discover' for hspec-discover-2.6.1..
hspec-discover  > Building executable 'hspec-discover' for hspec-discover-2.6.1..
hspec-discover  > [1 of 2] Compiling Main
hspec-discover  > [2 of 2] Compiling Paths_hspec_discover
hspec-discover  > Linking .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/hspec-discover/hspec-discover ...
hspec-discover  > copy/register
hspec-discover  > Installing library in /Users/anentropic/.stack/snapshots/x86_64-osx/9ea21a5325b81a2dfa4286ce80451092e847f54dde50f04e1f7e952425f2d334/8.6.5/lib/x86_64-osx-ghc-8.6.5/hspec-discover-2.6.1-GcEMs7l4z3NWJQPD5eMXU
hspec-discover  > Installing executable hspec-discover in /Users/anentropic/.stack/snapshots/x86_64-osx/9ea21a5325b81a2dfa4286ce80451092e847f54dde50f04e1f7e952425f2d334/8.6.5/bin
hspec-discover  > Registering library for hspec-discover-2.6.1..
Building all executables for `myproject' once. After a successful build of all of them, only specified executables will be rebuilt.
myproject> configure (lib + exe + test)
Configuring myproject-0.1.0.0...
myproject> build (lib + exe + test)
Preprocessing library for myproject-0.1.0.0..
Building library for myproject-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_waterloo_haskell
Preprocessing executable 'myproject-exe' for myproject-0.1.0.0..
Building executable 'myproject-exe' for myproject-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_waterloo_haskell
Linking .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/myproject-exe/myproject-exe ...
Preprocessing test suite 'myproject-test' for myproject-0.1.0.0..
Building test suite 'myproject-test' for myproject-0.1.0.0..
[1 of 2] Compiling Main

/Users/anentropic/Documents/Dev/Personal/waterloo/myproject/test/Spec.hs:3:1: error:
    Could not find module ‘Test.Hspec.Discover’
    Perhaps you meant
      Test.Hspec.Discover.Run (from hspec-discover-2.6.1)
      Test.Hspec.Discover.Sort (from hspec-discover-2.6.1)
    Use -v to see a list of the files searched for.


--  While building package myproject-0.1.0.0 using:
      /Users/anentropic/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build lib:myproject exe:myproject-exe test:myproject-test --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
Progress 2/3

我有很多不明白的地方。 但是,這里的主要難題是輸出似乎顯示成功安裝了hspec-discover-2.6.1

我尚未在代碼的任何位置編寫Test.Hspec.Discover ,因此我必須假設錯誤來自{-# OPTIONS_GHC -F -pgmF hspec-discover #-} (錯誤消息也指向Spec.hs因為資源)。

嗯,我在做什么錯? hspec-discover無法找到自己?

對該模塊名稱進行Hoogle搜索顯示該模塊名稱位於hspec中,而不位於hspec-discover中。 請嘗試在hspec上添加測試套件依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM