UnkindPartition / tasty

Modern and extensible testing framework for Haskell
640 stars 110 forks source link

QuickCheck: allow to print/specify seed for a failure without having to replay through previous successes #383

Closed amesgen closed 7 months ago

amesgen commented 1 year ago

If we find a property test failure after a lot of iterations, reproducing it is annoying as we have to replay all successful iterations to get to the failing test case. This is a bit annoying:

Also see https://github.com/hedgehogqa/haskell-hedgehog/pull/454 for a recent Hedgehog PR implementing this (and more).

I think this should be simple to implement in tasty-quickcheck as QuickCheck exposes the necessary seed in its Result:

data Result
  = ...
  | Failure
    { ...
    , usedSeed        :: QCGen
      -- ^ What seed was used
    , usedSize        :: Int
      -- ^ What was the test size
    ...
    }
...

data Args
  = Args
  { replay          :: Maybe (QCGen,Int)
    -- ^ Should we replay a previous test?
  , ...
  }

On failure, (usedSeed, usedSize) would be printed, and it could be specified via a new flag --quickcheck-exact-replay (name very tentative).

Happy to open a PR if this sounds like a useful addition.

Bodigrim commented 1 year ago

Overall makes sense to me, but hard to judge further without looking at a PR (ideally with tests).

facundominguez commented 8 months ago

I contributed a PR with a test.