Fixed
Status Update
Comments
sl...@google.com <sl...@google.com> #2
The link in the above description doesn't work external to google, expanded link: https://issuetracker.google.com/issues/73450636
v....@gmail.com <v....@gmail.com> #3
This will be fixed in the next release.
ai...@gmail.com <ai...@gmail.com> #4
I created sample project that can confirm this behaviour:
https://github.com/gildor/espresso-sample
When you run MainActivityTest and check logcat you can see that next test activity onCreate evaluated before previous test activity onDestroy -https://gist.github.com/gildor/dadd1824728db789617cd24e3132b823
Also you can check Espresso LifecycleMonitor -https://gist.github.com/gildor/5556b61651648786cfd19db7a93f5a4a
According LifecycleMonitor logs next test activity run onCreate, onStart and onResume before previous activity onStop and onDestroy
It's critical if you have shared resources or subscribe/unsubscribe for events on lifecycle
I understand that it not perfect architecture, but this behaviour can produce many strange and hard to fix bugs
As temporary workaround I added Thread.sleep(500) to rule afterActivityFinished()
When you run MainActivityTest and check logcat you can see that next test activity onCreate evaluated before previous test activity onDestroy -
Also you can check Espresso LifecycleMonitor -
According LifecycleMonitor logs next test activity run onCreate, onStart and onResume before previous activity onStop and onDestroy
It's critical if you have shared resources or subscribe/unsubscribe for events on lifecycle
I understand that it not perfect architecture, but this behaviour can produce many strange and hard to fix bugs
As temporary workaround I added Thread.sleep(500) to rule afterActivityFinished()
nk...@google.com <nk...@google.com>
ar...@gmail.com <ar...@gmail.com> #5
Looking for a solution, any updates on this?
nk...@google.com <nk...@google.com> #6
This will be fixed in next release. Meanwhile, look at comment #3 for a horrible but temporary solution. Thanks!
be...@gmail.com <be...@gmail.com> #8
Similar or related issue to this and https://code.google.com/p/android/issues/detail?id=216442 ? Executing a set of tests in a single class seem to work but running a suite of tests (@Suite junit4) seems to have similar failures.
fr...@gmail.com <fr...@gmail.com> #9
Hi, is there any news when the next release will be available? It's been almost a year since 2.2.2 and half a year since #6.
xa...@gmail.com <xa...@gmail.com> #10
Hi, is there any update on this bug?
vi...@gmail.com <vi...@gmail.com> #11
Hi guys,
please give us an update about the fix for this :)
It's making making using Espresso extremely unpleasant
please give us an update about the fix for this :)
It's making making using Espresso extremely unpleasant
to...@gmail.com <to...@gmail.com> #13
It's been about a month. When will the v1.0 release of Rules/Runner be released?
to...@gmail.com <to...@gmail.com> #15
We just tried to update our runner/rules, but test suite crashed :) I guess we may need to update Espresso to 3.0 as well.
jc...@gmail.com <jc...@gmail.com> #16
Any updates on this bug? Is this fixed?
nk...@google.com <nk...@google.com> #17
Yes, this was fixed for a while now. Please give it a try with the latest version of our libraries.
da...@gmail.com <da...@gmail.com> #19
Any other updates about this bug? I'm still issuing it with:
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test:rules:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Tests always passes individually.
Running the suite instead, they have an unpredictable behavior: sometimes they passes, sometimes do not.
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test:rules:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Tests always passes individually.
Running the suite instead, they have an unpredictable behavior: sometimes they passes, sometimes do not.
gu...@gmail.com <gu...@gmail.com> #20
For some reason with databinding and static class I cannot debug code in ViewModel at every 2 test. Individually everything is just fine. espresso 3.0.2
gu...@gmail.com <gu...@gmail.com> #21
This is works like this (everything is without package). In my View which is Activity I call onStart() and onPause() of ViewModel. In xml I have button with enabled set to MutableLiveData<Boolean> property in ViewModel. I write in Kotlin
//This is button enabled field update, each time when this MutableLiveData<Boolean> is called it prints this.toString()
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
//Second test start onStart() of ViewModel
START: PersonalViewModel@43321e0
PersonalViewModel@43321e0 //Calls button MutableLiveData<Boolean> for enabled property only ONCE
//Second test onPause() of ViewModel
PAUSE: PersonalViewModel@43321e0
//Third test start onStart() of ViewModel
START: PersonalViewModel@dc72c50
PersonalViewModel@dc72c50 //Calls button MutableLiveData<Boolean> for enabled property only ONCE
PAUSE: PersonalViewModel@dc72c50
When the second test starts it seems like it calls MutableLiveData<Boolean> property only once for button and then it fails to bind or something, because button is not updating anymore. Individually all tests work.
//This is button enabled field update, each time when this MutableLiveData<Boolean> is called it prints this.toString()
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
PersonalViewModel@52cb180
//Second test start onStart() of ViewModel
START: PersonalViewModel@43321e0
PersonalViewModel@43321e0 //Calls button MutableLiveData<Boolean> for enabled property only ONCE
//Second test onPause() of ViewModel
PAUSE: PersonalViewModel@43321e0
//Third test start onStart() of ViewModel
START: PersonalViewModel@dc72c50
PersonalViewModel@dc72c50 //Calls button MutableLiveData<Boolean> for enabled property only ONCE
PAUSE: PersonalViewModel@dc72c50
When the second test starts it seems like it calls MutableLiveData<Boolean> property only once for button and then it fails to bind or something, because button is not updating anymore. Individually all tests work.
Description
Version used: 2.2.1
What steps will reproduce the problem?
1. Have atleast 3 tests
2. Log messages in activity onCreate and onDestroy
3. Observe onCreate -> onDestroy messages not going in order (onCreate -> onDestroy, onCreate -> onDestroy, onCreate -> onDestroy)
How are you running your tests (via Android Studio, Gradle, adb, etc.)?
Android Studio 1.5.1
What is the expected output? What do you see instead?
Log messages going sequentially (onCreate -> onDestroy, onCreate -> onDestroy, onCreate -> onDestroy)
I am trying to use espresso and junit4. The problem seems to be that I have code that is statically initialized in activity.onCreate and deinitialized in activity.onDestroy to prevent leaks, etc.
Now when I run espresso, the tests seem to run in "parallel". I added log class to activity onCreate and onDestroy.
What I am seeing is
onCreate = example.package.MainActivity@ABC
onCreate = example.package.MainActivity@JKL
onDestroy = example.package.MainActivity@ABC
onCreate = example.package.MainActivity@XYZ
onDestroy = example.package.MainActivity@JKL
onDestroy = example.package.MainActivity@XYZ
**and ofcourse it fails on NPE in third test because the second test's onDestroy ran after third's onCreate (which null-ed out the static code)**
Is this behaviour normal? Can I force espresso to teardown activity instance first and only then start a new one? Thanks!