Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override QuickCheck Args on a per-test basis (Lighthouse #6) #45

Open
fatuhoku opened this issue Mar 28, 2013 · 0 comments
Open

Override QuickCheck Args on a per-test basis (Lighthouse #6) #45

fatuhoku opened this issue Mar 28, 2013 · 0 comments

Comments

@fatuhoku
Copy link

Reported by Oren Ben-Kiki | August 15th, 2012 @ 09:58 AM

I added something like this:

    quickCheckWithNewArgs :: QC.Testable prop => (Args -> Args)-> prop-> IO ()
    quickCheckWithNewArgs modifyArgs test = do
      result <- quickCheckWithResult (modifyArgs $ stdArgs { chatty = False }) test
      case result of
        Success {} ->
          return ()
        Failure {} ->
          assertFailure $ "QuickCheck failed\n" ++ extra result
        GaveUp {} ->
          assertFailure $ "QuickCheck gave up after: " ++ (show $ numTests result) ++ " tests\n" ++ extra result
        NoExpectedFailure {} ->
          assertFailure $ "QuickCheck failed to trigger expected failure\n" ++ extra result
      where
        extra result =
          output result ++ (concatMap showLabelFrequency $ labels result)
        showLabelFrequency (label, frequency) =
          "\nSeen label: " ++ label ++ " with frequency: " ++ show frequency

    quickCheckRepeatTests :: QC.Testable prop => Int-> prop -> IO ()
    quickCheckRepeatTests number test = do
      quickCheckWithNewArgs setTestsNumber test
      where
        setTestsNumber number args =
          args { maxSuccess = number }

It seems like something along these lines should be a part of test-framework-quickcheck2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant