-
Notifications
You must be signed in to change notification settings - Fork 123
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
Introduce time-bounded execution #402
Comments
As a maintainer of I wonder if it could be possible to share a mutable cell (say |
@Bodigrim there is really nothing stopping us doing both! There is at least one other issue (#399) talking about what interface we want for testing frameworks. I think it would be wise for you, @sol, and us to have a discussion (perhaps in that issue?) where we can hash out the details of how we want such an interface to be designed? |
You are the boss here :) Although mind you that it's important that
Sorry, I don't have much bandwidth these days to do open-ended design work myself, but feel free to ping me if you'd like to hear my opinion on anything specific. |
@MaximilianAlgehed so the idea is to have a time budget for each individual test case, right? QuickCheck then would use up the whole time budget. As a consequence, if you set your time budget to 100 ms and you have 100 test cases then your test suite would need 10 seconds to finish. The issue I see here is that this approach may very well just increase the runtime of your test suite, instead of limiting it. Even if you reduce the time budget to just 10 ms, your test suite would still run for one whole second. I don't see myself using this. What I generally try to do:
NB: As for properties where 100 repetitions take more than a couple of milliseconds to complete, this may just indicate that there is something wrong with my code (I probably wanna run this in production more than a 100 times without using an exorbitant amount of resources, right?), or maybe there is something wrong with my testing strategy. To get the maximum benefit from test driven development, my test suite needs to run fast. While in general, I want full test coverage, it doesn't buy me anything if it slows the whole team down. So the challenge here is really, how can I ensure reasonable test coverage without testes that run for 10s of seconds or CI jobs that run for hours. |
@sol the feature you describe already exists in As for your strategy of only running for a few seconds I personally think is misguided as a general rule but we should support it while also supporting users who want to run for hours (which I also think is misguided) and anything in between. Having this feature means one can support your strategy while also supporting e.g. nightly tests that can afford to run for longer than 2 seconds. |
As I said before, I don't see myself using it. There already is But if it gets added anyway, that's fine with me too.
Hspec mostly achieves what it needs to and I don't have too many free cycles to burn on "making things more beautiful". If there's something that makes the |
I repeat, this is not about dealing with pathological properties, it's about adding a convenient way of distributing resources between tests. |
Right now the only conventient way to control how long a test runs for in QuickCheck is by modifying
maxSuccess
in one way or another. However, this is a bit inconvenient when setting up test suites (e.g.hspec
) whose properties vary a lot in execution time.It would be nice to have a flag (e.g.
maxTestTime
) that tells QuickCheck "please keep testing for this long" to avoid having to set differentmaxSuccess
for different tests (and, more importantly, having to go through the slow and boring process of measuring execution time to figure out what it should be for each individual test!).There are a couple of questions that need to be resolved when designing this feature, however:
withMaxSuccess
?maxSuccess
aside the semantics ofwithMaxSuccess
is currently that other things (checkCoverage
) can make the tests run for more tests thanmaxSuccess
and in keeping with this it would probably be correct to keep the same semantics here: run for the maximum of the allocated time and the givenmaxSuccess
.checkCoverage
?maxSuccess
and keep going even if the coverage checker is happy.The text was updated successfully, but these errors were encountered: