-
Notifications
You must be signed in to change notification settings - Fork 30
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
TimeBox a Property test #341
Comments
Due to F# bug dotnet/fsharp#6984, you should not write tail recursive calls with pipe operators. |
This all seems reasonable to me. I think it could be directly added to Hedgehog. |
We may need to flesh out some "stop condition" concept in light of this. I've seen this come up in various ways:
I'd like to hear thoughts on how this could be unified or expressed better. I think keeping the API flexible with combinators and allowing the user to put them together however they wish is the best approach. As you've hinted at, I think we're reaching the limit of the "add another x option" approach. Edit: Perhaps separating these into two categories would be a good place to start: success conditions, and failure conditions. |
I'm building a
TimeboxedPropertyAttribute
for Hedgehog.Xunit. Its documentation:Raison d'être: I have some tests that take a while to run. During development, I don't care that much about correctness and will therefore timebox said tests. I'll flip them back to normal
property
tests before committing/merging. Since a test might only run once if the timebox is extremely short, I want a random size. (Always testing withSize=0
isn't great.) This is pretty niche to my workflow, but LMK if any of this sounds interesting and anyone wants it merged upstream.I'm currently implementing it via a hack (but without reflection):
Basically, I run the test once, see if the timebox is exceeded, and if not run it again, while manually incrementing the test count. A better solution would be to implement it in Hedgehog proper, but this hacky solution suited my needs. I'm willing to add it to Hedgehog if there's interest.
From this conversation:
Yep!
Right now I'm leaning in the direction of something on the level of property, i.e. a sibling of
checkWith
. Some of the qualities of a "TimeBoxedProperty" are at odds with the semantics and types of a normalcheckWith
test, so I don't think I can use the currentPropertyConfig
- I'll need aTimeBoxedPropertyConfig
. For example, I can imagine a scenario where someone would want to run a test without specifying the testcount and only specifying the timebox. The result will be a test that runs as many times as it can for, say, 1 second. Currentlytestcount
defaults to 100. Therefore it isn't enough to simply add an optionaltimebox
field toPropertyConfig
.Size
also needs to be optional, and when its in theNone
case we'll generate random sizes.Please feel free to consider this idea outside the scope of Hedgehog. I'm pretty sure Haskell doesn't do this!
The text was updated successfully, but these errors were encountered: