简体   繁体   中英

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. On cabal test it compiles and runs these tests like expected and gives a message for failing/passing.

Now I included a quickCheck test and even when this test fails the output in terminal don't recognize the quickCheck test.

But in the dist/test/ dir i can see the test log *** Failed! ... *** Failed! ...

Is there a way to "include" quickCheck tests in the test workflow. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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