我想扩展QuickCheck以在测试失败时给我更好的消息(而不仅仅是种子)。例如,我希望能够按照以下方式创建事物:
eqTest :: Eq a => a -> a -> TestResult
eqTest x y = if x == y
then HappyResult
else SadResult $ show x <> " /= " <> show y
或(带有Monoid
“停止”SadResult
并“继续”在上的实例HappyResult
,类似于(&&)
运算符 for TestResult
)
listEqTest :: Eq a => [a] -> [a] -> TestResult
listEqTest [] [] = HappyResult
listEqTest [] ys = SadResult $ "Ran out of xs to compare to " <> show ys
listEqTest xs [] = SadResult $ "Ran out of ys to compare to " <> show xs
listEqTest (x:xs) (y:ys) = eqTest x y <> listEqTest xs ys
如何扩展 QuickCheck 功能?或者,是否有一个更可扩展的随机测试库?
谢谢!