Skip to content
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

Consider API for default timeouts? #17

Open
alechenninger opened this issue Aug 1, 2014 · 1 comment
Open

Consider API for default timeouts? #17

alechenninger opened this issue Aug 1, 2014 · 1 comment

Comments

@alechenninger
Copy link
Member

ie...

expect(thingToHappen)
  .withTimeout(1, MINUTES)
  .await();

However this begs some questions:

  • Do we keep the waitUpTo(Duration) API as an "override" of the specified timeout?
  • Or do we remove it in favor of await() where the timeout is always specified with a separate clause? (I vote yes)
  • If we keep waitUpTo, do we rename it awaitUpTo to be consistent? (I vote yes, if we keep the API)

One neat consequence of this addition is that individual events in a MultiEvent or SequentialEvent can have different timeouts. Whichever times out first will throw a timeout exception, which is fine. Consider waiting for a spinner to come and go:

expect(spinnerToAppear)
  .withTimeout(10, SECONDS)
  .andThenExpect(spinnerToDisappear)
  .withTimeout(1, MINUTES)
  .await();

If the spinner doesn't first appear after 10 seconds, we'll get a timeout there. This is useful. Events are associated with their own timeouts, which makes sense. You can be waiting for multiple events, and each event might have vastly different expectations about how long they are allowed to take.

I guess in a MultiEvent it doesn't make that much sense because you're always returning the result of the first event that occurs, however you need only specify a timeout for one of the events, and that will suffice, functionally (however technically only one of the inner events will ever timeout which is a little odd).

@alechenninger
Copy link
Member Author

If await is implemented, what happens if no timeout is specified?

  • Throw a NoTimeoutSpecified exception? 😦
  • Wait forever by default?
  • Allow configurable default timeout statically?

What happens in this scenario...

expect(spinnerToAppear)
  // No timeout
  .andThenExpect(spinnerToDisappear)
  .withTimeout(1, MINUTES)
  .await();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant