How to get Haskell QuickCheck 2.4 to increase # tests?
-
28-02-2021 - |
Pergunta
Okay, as I learned via my previous question, the RWH book is already out of date for QuickCheck. And despite all the posts I've read that tell me how incredibly simple it is to use QuickCheck, I cannot find any place that tells me how to change the number of tests to run for a property.
RWH says:
handyCheck limit = check defaultConfig {
configMaxTest = limit
, configEvery = \_ _ -> ""
}
How to do this with QuickCheck 2.4? More importantly, how would I have found out myself? Please don't tell me that I should've been able to figure it out from the API documentation.
Solução
You are looking for:
quickCheckWith stdArgs { maxSuccess = 5000 } someProp
How I found out
- I went to the API documentation.
- The 2nd thing I saw, after
quickCheck
was theArgs
type with amaxSuccess
field. - I didn't want to write all the fields, so I looked for a value of type
Args
- findingstdArgs
. (Use your browsers search function - ctrl-f usually). OTOH, I could have used hoogle. - I needed to use my
Args
type somewhere so I kept looking. The next line wasquickCheckWith
- bingo! On the other hand, I could have used hoogle.
How Else Can You Find Out
As I stated above, you could have used hoogle to find a lot of the functions, assuming you realize the Args
type is the core of what you need (from the haddocks).
Otherwise, you are probably reduced to looking at what other packages do, which means you need to know what other packages are worth looking at. The examples folder in QuickCheck seems obvious, but not all packages include such examples. Using reverse dependencies you can often find a package to look at, but for QC lots of packages don't have explicit dependencies.
Outras dicas
For those who want to run all tests at once and provide their configuration:
return []
main = $forAllProperties (quickCheckWithResult stdArgs { maxSuccess = 500 })