-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce declarative timeouts #1885
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1885 +/- ##
============================================
+ Coverage 91.42% 91.58% +0.16%
- Complexity 4149 4225 +76
============================================
Files 351 356 +5
Lines 9978 10133 +155
Branches 802 814 +12
============================================
+ Hits 9122 9280 +158
+ Misses 659 654 -5
- Partials 197 199 +2
Continue to review full report at Codecov.
|
...t-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutDurationParser.java
Outdated
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutInvocation.java
Show resolved
Hide resolved
39052ec to
8fb796d
Compare
sbrannen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass at a review. Haven't reviewed the extension implementation or tests in detail yet.
junit-jupiter-api/src/main/java/org/junit/jupiter/api/Timeout.java
Outdated
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutConfiguration.java
Show resolved
Hide resolved
...t-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutDurationParser.java
Outdated
Show resolved
Hide resolved
dfde7be to
d535bbf
Compare
...t-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/TimeoutExtensionTests.java
Show resolved
Hide resolved
| .isNotEqualTo("foo") // | ||
| .isNotEqualTo(new TimeoutDuration(2, SECONDS)) // | ||
| .isNotEqualTo(new TimeoutDuration(1, MINUTES)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcphilipp Have you considered using EqualsVerifier here? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping :)
sbrannen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is coming along very nicely. Great work!
I've requested a few minor changes.
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/Constants.java
Outdated
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutConfiguration.java
Outdated
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutExtension.java
Outdated
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutExtension.java
Outdated
Show resolved
Hide resolved
...t-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/TimeoutExtensionTests.java
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutExtension.java
Outdated
Show resolved
Hide resolved
275c102 to
f78e9cc
Compare
c1d5583 to
26bb440
Compare
26bb440 to
2a2850c
Compare
sbrannen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the previous round of updates!
Hopefully this is my final set of review comments and questions.
This PR introduces declarative timeouts for testable and lifecycle methods. The API surface consists of a new
@Timeoutimplementation that can be applied to@Test,@TestTemplate,@TestFactory, and lifecycle methods. In addition, it can be applied to a test class which has the same meaning as declaring it on all of its testable, but not its lifecycle methods.Moreover, default timeouts can be defined using configuration parameters for all of the above methods, all lifecycle methods, all testable methods, or each type individually.
The timeout is implemented in a preemptive manner, but without having to execute the test in a different thread. Instead, a single-thread
ExecutorServiceis used to schedule interrupting the original test thread. This way,ThreadLocalwill continue to work which is important for integration tests that use frameworks like Spring and its@Transactionalsupport.Resolves #80.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotations