UserPreferences

IssueFive/Feedback/SoftwareTestingWithHaskell


This article spurred me to explore HUnit a little more. So far I haven't figured out how to induce failures (as opposed to errors). I encoded my expectations in the test case names used in the fragment below.

import Test.HUnit

tests = TestList
        [TestCase $ assertEqual "success" 1 $ head [1,2,3]
        ,TestCase $ assertEqual "failure" 1 $ head [2,3,4]
        ,TestCase $ assertEqual "error"   1 $ head []
        ]

Running it, I see...

*Main> runTestTT tests
### Error in:   1
user error (HUnit:failure
expected: 1
 but got: 2)
### Error in:   2
Prelude.head: empty list
Cases: 3  Tried: 3  Errors: 2  Failures: 0
*Main> 

HUnit does see that the first mistake is different from the second and I think the last line should be...

Cases: 3  Tried: 3  Errors: 1  Failures: 1

Of course I realize that ShaeErisson is not the author of HUnit and that this is barely a bug, if it is at all. It's just that I noticed this and thought I'd try editing this wiki while it was on my mind. Perhaps it's my expectations that need adjusting.


how about [WWW]bug report and patch?