Hspec: A Testing Framework for Haskell

Using QuickCheck with Hspec

You can use arbitrary QuickCheck properties with Hspec, but they must be of type Property. QuickCheck's property function can be used to turn anything that is a member of the Testable class into a Property. Here is an example:

describe "read" $ do
  it "is inverse to show" $ property $
    \x -> (read . show) x == (x :: Int)
Example code:
-- file Spec.hs
import Test.Hspec
import Test.QuickCheck

main :: IO ()
main = hspec $ do
  describe "read" $ do
    context "when used with ints" $ do
      it "is inverse to show" $ property $
        \x -> (read . show) x == (x :: Int)
runhaskell Spec.hs

read
  when used with ints
    is inverse to show

Finished in 0.0034 seconds
1 example, 0 failures