找不到模块“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 search 表明它在 hspec 中,而不是 hspec-discover。请尝试添加对 hspec 的测试套件依赖。
我是菜鸟
我尝试将一个更大的项目中的单个 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 search 表明它在 hspec 中,而不是 hspec-discover。请尝试添加对 hspec 的测试套件依赖。