例如我有一个这样的测试代码:
import Data.Decimal
import Data.Ratio
import Data.Word
import Test.HUnit
import Control.Applicative
import Debug.Trace
import Test.QuickCheck
import qualified Test.QuickCheck.Property as P
import Test.Framework as TF (defaultMain, testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.Framework.Providers.QuickCheck2 (testProperty)
............
isEQ :: (Eq a, Show a) => a -> a -> P.Result
isEQ a b = if a == b
then P.succeeded
else P.failed {P.reason = show a ++ "\nis not equal to \n" ++ show b}
-- | "read" is the inverse of "show".
--
-- > read (show n) == n
prop_readShow :: Decimal -> P.Result
prop_readShow d = isEQ (read (show d)) d
......
tests = [
testGroup "QuickCheck Data.Decimal" [
testProperty "readShow" prop_readShow,
testProperty "readShowPrecision" prop_readShowPrecision,
testProperty "fromIntegerZero" prop_fromIntegerZero,
.....................
test-framerowk 的报告是这样的
dist/build/Main/Main -a2000
QuickCheck Data.Decimal:
readShow: [Failed]
Arguments exhausted after 0 tests
readShowPrecision: [Failed]
Arguments exhausted after 0 tests
fromIntegerZero: [Failed]
没有任何失败的原因。看起来相同的 HSpec 测试会在报告中打印失败原因,但测试框架测试不会。