-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Create TimeoutRule which can be used with Robolectric in place of org.junit.rules.Timeout #9037
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
@fknives Thanks for your contribution. Please check GitHub Action for commit message validation job and make your PR pass the CI. |
|
@utzcoz I didn't realize, I've added a body to the commit message, sorry about that |
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.
LGTM, except some nits notes.
robolectric/src/main/java/org/robolectric/junit/rules/TimeoutRule.java
Outdated
Show resolved
Hide resolved
@fknives Please check Robolectric code style CI job, and ensure your code are formatted locally. |
@utzcoz Adjusted the docs and applied google-java-format. Hopefully everything is right now 🤞 , thank you for your patience |
There still exists some format issues. You can check https://github.com/robolectric/robolectric/wiki/Robolectric's-code-style to fix it. |
@utzcoz Right, the TimeLimitedStatement wasn't formatter properly either, ohh my |
@fknives Please rebase your PR based on latest master branch as I merged some commits to make CI green. |
org.junit.rules.Timeout is incompatible with Robolectric's scheduler because it spawns a new thread for the test. This commit introduces TimeoutRule which behaves like `@Test(timeout = )` but for all tests in the file
@fknives Thanks for your contribution, and congrats to your first contribution for Robolectric. I think it will be released with Robolectric 4.13, and you can use Robolectric 4.13-snapshot now to test it. |
Overview
Close #3829
org.junit.rules.Timeout
JUnit rule is not compatible with Robolectric because it starts a separate execution Thread.Robolectric's
@Test(timeout = )
usesTimeLimitedStatement
which evaluates the statement on the same thread & moves the timeout & interruption into a separate thread.Proposed Changes
Introduces a Timeout Test rule which uses the same TimeLimitedStatement to be used in place of
org.junit.rules.Timeout