-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feature: add timeout of Step and Scenario #343
Comments
How would you like to specify a timeout? Code please. |
eg1: |
Can you give some example of long-running activity that might happen in a step definition that you would want to time out? |
Well I've run into this and found an issue. Eg. If I know that a certain step is taking 1 minute to execute at most. Then if the step is not executed in that 1 minute the step should timeout. Excuse me if I'm referring to a new feature, and didn't understood the timeout feature written here. |
I recommend you take a look at TimeoutTest and Timeout and see if you can modify them to reproduce the behaviour you're seeing. |
If a thread does not respond to interrupt() we'll try to stop() it after twice the specified timeout. This uses the deprecated Thread.stop() method, but for a testing tool like Cucumber that should be ok. Ref #343.
Well it's an ok approach not the best. |
@paul8620 what would be a better approach in your opinion? |
First this is what actually happens public class TimeoutTest {
@Test(expected = TimeoutException.class)
public void times_out_on_infinite_loop() throws Throwable {
final Slow slow = new Slow();
Timeout.timeout(new Timeout.Callback<Void>() {
@Override
public Void call() throws Throwable {
slow.infiniteLoop();
return null;
}
}, 10);
fail();
}
}
public static class Slow {
public String slow(int millis) throws InterruptedException {
sleep(millis);
return String.format("slept %sms", millis);
}
public void infiniteLoop(){
while(true)
{
}
}
public void infinite() throws InterruptedException {
while (true) {
sleep(1);
}
}
public void infiniteLatchWait() throws InterruptedException {
new CountDownLatch(1).await(); |
You should implement a timeout that lasts the specified timeout not twice the amount of timeout :D |
@paul8620 Can you format your code with GFM please? I can't read it. The reason I'm doubling the timeout is that we want to give it a chance to interrupt the thread before stopping it. Stopping the thread is a last resort strategy. I think what we really need to do is to look at how this is implemented in JUnit. They seem to have a solution that works. Let's continue the discussion in #811 - this issue is closed. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
…fter which a is thrown if the stepdef/hook has not completed. Closes #343
timeout of step or scenario could be used for assert time of duration
The text was updated successfully, but these errors were encountered: