[Haskell] ANNOUNCE: hspec-0.4.3 (color output and alternate mondaic api)

Trystan Spangler trystan.s at comcast.net
Tue Apr 19 07:17:27 CEST 2011


hspec version 0.4.3, Behavior Driven Development for Haskell, is now available!

Improvements include red/yellow/green color output and writing output as the tests are running.

Also, you can import Test.Hspec.Monadic rather than Test.Hspec if you want to use a WriterMonad based api.

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, using the new alternate monadic api, running this program:

> import Test.Hspec.Monadic
> import Test.Hspec.HUnit
> import Test.Hspec.QuickCheck (property)
> import Test.HUnit (assertBool, assertEqual)
> 
> main = hspec specs
> 
> specs = describe "hspec 0.4.3" $ do
>  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 "still shows a list of failed examples"
>      (undefined :: Bool) -- expected to fail
> 
>  it "still collects better data from failed HUnit examples"
>      (assertEqual "this should fail" 1 2) -- expected to fail
> 
>  it "still collects better data from failed QuickCheck examples"
>      (property $ \ i -> (i::Int) * 2 - 2 /= i) -- expected to fail
> 
>  it "now allows a monadic api"
>      (pending "I'm still not sure how to test this but this example is good evidence....")
>  
>  it "now outputs in color when writing to stdout"
>      (pending "I'm still not sure how to test this but trust me it works....")

should send this to stdout in glorious red, yellow, and green:

hspec 0.4.3
 - 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 still shows a list of failed examples FAILED [1]
 x still collects better data from failed HUnit examples FAILED [2]
 x still collects better data from failed QuickCheck examples FAILED [3]
 - now allows a monadic api
     # I'm still not sure how to test this but this example is good evidence....
 - now outputs in color when writing to stdout
     # I'm still not sure how to test this but trust me it works....

1) hspec 0.4.3 still shows a list of failed examples FAILED
Prelude.undefined

2) hspec 0.4.3 still collects better data from failed HUnit examples FAILED
this should fail
expected: 1
 but got: 2

3) hspec 0.4.3 still collects better data from failed QuickCheck examples FAILED
*** Failed! Falsifiable (after 6 tests):  
2


Finished in 0.0520 seconds

8 examples, 3 failures

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell/attachments/20110418/555f3c39/attachment.htm>


More information about the Haskell mailing list