The likely problem here is that QuickCheck is giving up after finding too many unsuitable test cases. Raising topt_maximum_unsuitable_generated_tests
will give QuickCheck more opportunities to find acceptable cases and allow the test to finish.
How to make Test-Framework to report about the reason of QuickCheck's fail?
-
15-03-2022 - |
Pregunta
For example I have a testing code like this:
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,
.................
the report of test-framerowk looks like this
dist/build/Main/Main -a2000
QuickCheck Data.Decimal:
readShow: [Failed]
Arguments exhausted after 0 tests
readShowPrecision: [Failed]
Arguments exhausted after 0 tests
fromIntegerZero: [Failed]
without any reason of the fail. The same looking HSpec tests print the fail reason in the report, but test-framework tests does not.
Solución
Otros consejos
That was a different issue, in fact test-framework-0.8 has a bug https://github.com/batterseapower/test-framework/issues/34 so the high values of tests count (-a parameter) lead to fail.
You just need to reduce the version of test-framework to 0.7.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow