【问题标题】:How to use QuickCheck in Hspec tests?如何在 Hspec 测试中使用 QuickCheck?
【发布时间】:2018-07-30 11:45:33
【问题描述】:

我使用cabal init 为我的 Haskell 项目构建初始代码库 我有几个用 Hspec 编写的测试。 在cabal test 上,它按预期编译和运行这些测试,并给出失败/通过的消息。

现在我加入了 quickCheck 测试,即使该测试失败,终端中的输出也无法识别 quickCheck 测试。

但是在 dist/test/ 目录中我可以看到测试日志*** Failed! ...

有没有办法在测试工作流程中“包含”quickCheck 测试。这样我就不必在每次测试运行后查看测试日志。

import Test.Hspec
import Test.QuickCheck

spec :: Spec
spec = do
    describe "myTest" $ do
        it "Something something" $ do
            myTest "" `shouldBe` False
            quickCheckWith stdArgs { maxSuccess = 1000 } prop_myTest -- <== ?

【问题讨论】:

    标签: haskell tdd cabal quickcheck property-testing


    【解决方案1】:

    您想要property 功能,请参阅here

    例子:

    spec :: Spec
    spec = do
        describe "myTest" $ do
            it "Something something" $
                property prop_myTest
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多