Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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! ...

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 -- <== ?
like image 919
chrisheyn Avatar asked Mar 06 '23 17:03

chrisheyn


1 Answers

You want the property function, see here.

Example:

spec :: Spec
spec = do
    describe "myTest" $ do
        it "Something something" $
            property prop_myTest
like image 193
Cubic Avatar answered Mar 16 '23 21:03

Cubic