hspec-hedgehog: Integrate Hedgehog and Hspec!

[ bsd3, library, testing ] [ Propose Tags ]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.0.1, 0.0.1.0, 0.0.1.1, 0.0.1.2, 0.1.0.0, 0.1.1.0 (info)
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), hedgehog (>=1.0.2 && <2), hspec (>=2.4.4 && <3), hspec-core (>=2.4.4 && <3), HUnit (>=1.5 && <2), QuickCheck (>=2.9.2 && <3), splitmix (>=0.0.1 && <1) [details]
License BSD-3-Clause
Copyright 2020 Matt Parsons
Author Matt Parsons
Maintainer parsonsmatt@gmail.com
Revised Revision 1 made by parsonsmatt at 2020-04-12T17:46:19Z
Category Testing
Home page https://github.com/parsonsmatt/hspec-hedgehog#readme
Bug tracker https://github.com/parsonsmatt/hspec-hedgehog/issues
Source repo head: git clone https://github.com/parsonsmatt/hspec-hedgehog
Uploaded by parsonsmatt at 2020-03-03T04:12:12Z
Distributions Arch:0.0.1.2, LTSHaskell:0.1.1.0, NixOS:0.1.1.0, Stackage:0.1.1.0
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 5771 total (78 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-03-03 [all 1 reports]

Readme for hspec-hedgehog-0.0.1.0

[back to package description]

hspec-hedgehog

Build Status

An integration library for hspec and hedgehog.

Example:

import           Control.Concurrent     (threadDelay)
import           Control.Monad.IO.Class (liftIO)
import qualified Hedgehog.Gen           as Gen
import qualified Hedgehog.Range         as Range
import           Test.Hspec             (before, describe, hspec, it, shouldBe)
import           Test.Hspec.Hedgehog    (PropertyT, diff, forAll, hedgehog,
                                         (/==), (===))

main :: IO ()
main = hspec $ do
    describe "regular tests" $ do
        it "works" $ do
            True `shouldBe` True

    describe "hedgehog" $ do
        it "is useful if you get an ambiguous error" $ hedgehog $ do
            "no ambiguity" === "no ambiguity"

    describe "hedgehog tests" $ do
        it "lets you use PropertyT directly" $ hedgehog $ do
            x <- forAll $ Gen.integral (Range.linear 0 1000)
            y <- forAll $ Gen.integral (Range.linear 0 5000)
            diff (x + y) (>=) x

        it "renders a progress bit" $ hedgehog $ do
            x <- forAll $ Gen.integral (Range.linear 0 1000)
            y <- forAll $ Gen.integral (Range.linear 1 5000)
            liftIO $ threadDelay (100 * x + y)

    describe "with hooks" $ do
        before (pure "Hello!") $ do
            it "has functions" $ \str -> hedgehog $
                str === "Hello!"

            it "goes before or after" $ \str -> do
                pure () :: PropertyT IO ()
                str === "Hello!"

            it "generates" $ \str -> hedgehog $ do
                wrongLen <- forAll $ Gen.integral (Range.linear 0 3)
                length str /== wrongLen