-
Notifications
You must be signed in to change notification settings - Fork 122
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
Improve Constraint Documentation #163
Comments
@aaron868 Thanks for your interest in junit-quickcheck! Sorry for the late reply. It's up to individual generators to decide when configuration annotations to admit. You can find these as methods with signature
For purposes of resolving this issue -- what form would you imagine the additional documentation to take? |
The construct @when(satisfies = expr) would work. I don't see, however, a reference guide for constraint expressions. The link you provided (http://pholser.github.io/junit-quickcheck/site/0.7/usage/constraining.html) does not provide one. I assume that the constraints allowed are the OGNL operators. Could you add a few more examples of using them in the this library? |
@aaron868 Sure thing. Any OGNL expression that evaluates to I'll add a couple more examples of the usage of |
This ocde is a variation on the documentation. Why does this test fail?
I get: com.pholser.junit.quickcheck.internal.generator.PropertyParameterGenerationContext$DiscardRatioExceededException: For parameter [junitquickcheck.QuickCheck.when:arg0] with discard ratio [10], 11 unsuccessful values and 0 successes. Stopping. But if I change it to:
Then it works. It seems to me like the && is not doing an AND but an OR in the satisfies clause but perhaps I am missing something about how @when works. |
@bjordan2010 Thanks for this ... will investigate. |
@bjordan2010 I should mention also that if you want to guarantee that the generated values fall within the range you want, you can mark the parameter with @Property public void inRange(@InRange(min = 1001, max = 9999) int i) {
// ...
} |
When the expr is As noted above, your better bet is to use the |
Then the example of @when in the documentation 0 <= x <= 9 is also likely to fail since it alludes to looking for "Single Digits" for an integer correct? It makes it seem like those are the only values that will be generated but that is not the case. |
@bjordan2010 Correct. I wonder if |
Nice library. I've been experimenting with different tests but cannot find documentation about the possible constraints. For example, how do you constrain a String to length 1? Could you please add documentation (along with examples) on the constraints for each of the supported basic types?
Thanks.
The text was updated successfully, but these errors were encountered: