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

Introduce lambda based timeout assertions #438

Closed
1 task done
sbrannen opened this issue Jul 26, 2016 · 1 comment
Closed
1 task done

Introduce lambda based timeout assertions #438

sbrannen opened this issue Jul 26, 2016 · 1 comment

Comments

@sbrannen
Copy link
Member

sbrannen commented Jul 26, 2016

Status Quo

Assertions provides assertThrows and expectThrows for expected exceptions but does not provide support for asserting timeouts.

Deliverables

  • Introduce lambda based timeout support in Assertions.
@sbrannen sbrannen added this to the 5.0 M3 milestone Jul 26, 2016
@sbrannen sbrannen self-assigned this Jul 26, 2016
@sbrannen sbrannen changed the title Introduce lamba based timeout assertions Introduce lambda based timeout assertions Jul 26, 2016
sbrannen added a commit that referenced this issue Jul 26, 2016
This commit introduces assertTimeout() methods in Assertions that
support both lazy and preemptive timeouts for blocks of code supplied
as lambda expressions.

For example, the following assertion would pass:

assertTimeout(ofMillis(500), () -> Thread.sleep(10));

Whereas, the following assertion would fail:

assertTimeout(ofMillis(10), () -> Thread.sleep(500));

The above examples execute the code block in the same thread as the
caller. To perform the same assertions and have the code executed in a
separate thread and then preemptively aborted, the above can be
rewritten as follows.

assertTimeoutPreemptively(ofMillis(10), () -> Thread.sleep(500));

Issue: #438
sbrannen added a commit that referenced this issue Jul 27, 2016
This commit introduces assertTimeout() methods in Assertions that
support both lazy and preemptive timeouts for blocks of code supplied
as lambda expressions.

For example, the following assertion would pass:

assertTimeout(ofMillis(500), () -> Thread.sleep(10));

Whereas, the following assertion would fail:

assertTimeout(ofMillis(10), () -> Thread.sleep(500));

The above examples execute the code block in the same thread as the
caller. To perform the same assertions and have the code executed in a
separate thread and then preemptively aborted, the above can be
rewritten as follows.

assertTimeoutPreemptively(ofMillis(10), () -> Thread.sleep(500));

Issue: #438
sbrannen added a commit that referenced this issue Jul 27, 2016
This commit introduces assertTimeout() methods in Assertions that
support both lazy and preemptive timeouts for blocks of code supplied
as lambda expressions.

For example, the following assertion would pass:

assertTimeout(ofMillis(500), () -> Thread.sleep(10));

Whereas, the following assertion would fail:

assertTimeout(ofMillis(10), () -> Thread.sleep(500));

The above examples execute the code block in the same thread as the
caller. To perform the same assertions and have the code executed in a
separate thread and then preemptively aborted, the above can be
rewritten as follows.

assertTimeoutPreemptively(ofMillis(10), () -> Thread.sleep(500));

Issue: #438
@sbrannen
Copy link
Member Author

Merged into master in 0aa724b.

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

2 participants