Fixed
Status Update
Comments
nk...@google.com <nk...@google.com>
nk...@google.com <nk...@google.com> #2
This is a terrible oversight on our part but unfortunately there is no clean way to revert this API in order to break Guava dependency.
As a result, there will be a breaking public API change in the next release to address this issue. We introduced an ugly wrapper around Guava Optional class, named EspressoOptional which will live under "android.support.test.espresso.util" namespace. Developers that were using the leaked Guava Optional API will need to change their imports and references to use EspressoOptional during the update to the new version.
Sorry for the inconvenience this may cause. We'll make sure to add a note for this in the next release announcement and change-logs.
As a result, there will be a breaking public API change in the next release to address this issue. We introduced an ugly wrapper around Guava Optional class, named EspressoOptional which will live under "android.support.test.espresso.util" namespace. Developers that were using the leaked Guava Optional API will need to change their imports and references to use EspressoOptional during the update to the new version.
Sorry for the inconvenience this may cause. We'll make sure to add a note for this in the next release announcement and change-logs.
Description
Version used:
What steps will reproduce the problem?
1. Call IntentsTestRule.launchActivity, and then finish activity
2. Call IntentsTestRule.launchActivity again in the same test case
3. Crash
How are you running your tests (via Android Studio, Gradle, adb, etc.)?
adb instrument
What is the expected output? What do you see instead?
The below error causes the Activity crash.
java.lang.IllegalStateException: #init was called twice in a row. Make sure to call #release after every #init
at android.support.test.espresso.intent.Checks.checkState(Checks.java:75)
at android.support.test.espresso.intent.Intents.internalInit(Intents.java:252)
at android.support.test.espresso.intent.Intents.init(Intents.java:133)
at android.support.test.espresso.intent.rule.IntentsTestRule.afterActivityLaunched(IntentsTestRule.java:59)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:308)
The problem is that afterActivityLaunched is invoked 2 times, but afterActivityFinished is not called when activity finishes but until tearDown.
I think the fix is to call afterActivityFinished when activity finishes.