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

resetStaticState() happening too early/unnecessarily #2107

Closed
kriegfrj opened this issue Oct 23, 2015 · 1 comment
Closed

resetStaticState() happening too early/unnecessarily #2107

kriegfrj opened this issue Oct 23, 2015 · 1 comment

Comments

@kriegfrj
Copy link
Contributor

While working on the shadow for AsyncTask (#2095), I tried to get it to use more real Android. Because the real Android class stores some static state, I thought it would be a good idea to reset that static state (to the extent possible) in the shadow's @Resetter method. Unfortunately, this causes the JVM to attempt to initialize the AsyncTask class, which in turn tries (indirectly) to reference the main looper, which in turn fails because RobolectricTestRunner has not yet called prepareMainLooper(), which results in the test aborting with an InitializationError or something similar.

I tried to work around this by simply removing the "pre" call to resetStaticState() and leaving only the "post" call, but this caused some other issues with static state that were hard to track down because they depended on the run order.

I seem to recall running into the same issue with another shadow I was working on (possibly ShadowLooper itself).

@jongerrish
Copy link
Contributor

I think this has been fixed now.

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

No branches or pull requests

2 participants