[Haskell] ANNOUNCE: hspec-0.3.0 (better reporting of failed examples)
Trystan Spangler
trystan.s at comcast.net
Thu Mar 3 01:49:58 CET 2011
hspec version 0.3.0, Behavior Driven Development for Haskell, is now available!
Improvements include fixing a base dependancy problem and better reporting of failed examples.
Much thanks to Greg Weber for fixes and ideas!
http://hackage.haskell.org/package/hspec
https://github.com/trystan/hspec
As always, any advice, comments, or questions are welcome,
Trystan Spangler
For those who would like to see an example, running this program:
> import Test.Hspec
> import Test.Hspec.HUnit
> import Test.Hspec.QuickCheck (property)
> import Test.HUnit (assertBool, assertEqual)
>
> main = hspec specs
>
> specs = describe "hspec 0.3.0" [
> it "still allows a Bool expression to act as an example"
> (replicate 5 1 == [1,1,1,1,1]),
>
> it "still allows HUnit assertions to act as examples"
> (assertBool "lame example" True),
>
> it "still allows QuickCheck properties to act as examples"
> (property $ \ i -> (i::Int) == i + 1 - 1),
>
> it "now shows a list of failed examples"
> (undefined :: Bool), -- expected to fail
>
> it "now collects better data from failed HUnit examples"
> (assertEqual "this should fail" 1 2), -- expected to fail
>
> it "now collects better data from failed QuickCheck examples"
> (property $ \ i -> (i::Int) * 2 - 2 /= i) -- expected to fail
> ]
should send this to stdout:
hspec 0.3.0
- still allows a Bool expression to act as an example
- still allows HUnit assertions to act as examples
- still allows QuickCheck properties to act as examples
x now shows a list of failed examples [1]
x now collects better data from failed HUnit examples [2]
x now collects better data from failed QuickCheck examples [3]
1) hspec 0.3.0 now shows a list of failed examples FAILED
Prelude.undefined
2) hspec 0.3.0 now collects better data from failed HUnit examples FAILED
this should fail
expected: 1
but got: 2
3) hspec 0.3.0 now collects better data from failed QuickCheck examples FAILED
*** Failed! Falsifiable (after 4 tests):
2
Finished in 0.0494 seconds
6 examples, 3 failures
More information about the Haskell
mailing list