简体   繁体   English

如何在Hspec测试中使用QuickCheck?

[英]How to use QuickCheck in Hspec tests?

I build the initial codebase for my Haskell project with cabal init I have several tests written with Hspec. 我使用cabal init为我的Haskell项目构建初始代码库我有几个用Hspec编写的测试。 On cabal test it compiles and runs these tests like expected and gives a message for failing/passing. cabal test它会像预期的那样编译和运行这些测试,并给出失败/传递的消息。

Now I included a quickCheck test and even when this test fails the output in terminal don't recognize the quickCheck test. 现在我加入了一个quickCheck测试,即使测试失败,终端输出也无法识别quickCheck测试。

But in the dist/test/ dir i can see the test log *** Failed! ... 但是在dist / test / dir我可以看到测试日志*** Failed! ... *** Failed! ...

Is there a way to "include" quickCheck tests in the test workflow. 有没有办法在测试工作流程中“包含”quickCheck测试。 So that i don't have to look on the test log after every test run. 因此,我不必在每次测试运行后查看测试日志。

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 -- <== ?

You want the property function, see here . 你想要属性函数,请看这里

Example: 例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM