1

如何在 HSpec 中指定测试套件?我将为我*.hs的每个模块创建多个测试文件,我只想运行stack test并运行所有测试。我该如何设置?

我试图在我的 cabal 文件中列出这样的测试模块,但它不起作用:

test-suite foo-test
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Spec.hs
                     , Mod1Spec.hs
  build-depends:       base
                     , containers >= 0.5.6.2
                     , hqfl
                     , hspec >= 2.2.3
                     , hspec >= 2.2.3
                     , mtl >= 2.2.1
                     , pipes >= 4.1.8
                     , random >= 1.1
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  default-language:    Haskell2010
4

1 回答 1

5

这是一些关于 hspec 测试的文档:

http://hspec.github.io/hspec-discover.html

如果您的主要规范模块仅包含以下行:

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

hspec-discover将扫描目录树以进行规范测试。

另外 - 这是一个小的 hspec 示例:

https://github.com/hspec/hspec-example

于 2016-06-04T12:09:29.927 回答