-
Notifications
You must be signed in to change notification settings - Fork 319
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
NoMatchingViewException leaks view hierarchies until test suite finishes #1661
Comments
Hi, |
It is possible to solve this by making |
@ralf-at-android Would you be ok with the solution @TWiStErRob is describing? I do think it makes sense that you'd be able to access the view hierarchy as long as it's attached (i.e. essentially soon after the test fails) but once that UI is gone then Espresso should stop holding on to it. To do this right, we'd probably need to also take care of the list of adapter views (=> |
Any development on this issue? |
It will be nice that now that 3.6.0 has been released to have this fixed.
|
Description
While a test suite is running, the
AndroidJUnitRunner
thread holds the test suite result in a local variable of typeorg.junit.runner.Result
whereResult.failures
is a list oforg.junit.runner.notification.Failure
and eachFailure
has aFailure.fThrownException
that points to the thrown exception, which here is aandroidx.test.espresso.NoMatchingViewException
. Unfortunately,NoMatchingViewException
has a strong reference to the root view where the exception was thrown.This means that while the test suite is running, any test failing due to a view matching error will leak to the corresponding root view being leaked for the duration of the test suite. This increases memory pressure. Developers who run LeakCanary in tests might see subsequent tests fail due to a leak being detected, when that leak is actually caused by the Espresso.
Steps to Reproduce
Expected Results
AndroidX Test and Android OS Versions
All versions of AndroidX Test and all versions of Android.
Link to a public git repo demonstrating the problem
square/leakcanary#2297
The text was updated successfully, but these errors were encountered: