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

LeakCanary runs in UI tests by default #1382

Closed
pyricau opened this issue Jun 5, 2019 · 1 comment · Fixed by #1436
Closed

LeakCanary runs in UI tests by default #1382

pyricau opened this issue Jun 5, 2019 · 1 comment · Fixed by #1436
Milestone

Comments

@pyricau
Copy link
Member

pyricau commented Jun 5, 2019

Not quite sure what we should do here, but out of the box LeakCanary runs in any debug environment. While we do support running LeakCanary in instrumentation tests, this is an intentional step that requires an extra dependency and config. It's not clear that the right default behavior is for LeakCanary to run in UI tests.

Is there a way to detect that we're running in UI tests?

In the mean time, we can recommend the following code in UI Tests:

LeakSentry.config = LeakSentry.config.copy(enabled = false)
@pyricau pyricau added this to the 2.0 Next Release milestone Jun 5, 2019
@pyricau
Copy link
Member Author

pyricau commented Jun 5, 2019

Maybe we can use the <instrumentation> tag.

https://developer.android.com/reference/android/app/Instrumentation.html

When running with instrumentation turned on, this class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application.

We could add an <instrumentation> tag to a subclass of Instrumentation, and if that is loaded then we know we're in tests

pyricau added a commit that referenced this issue Jul 3, 2019
This makes the assumption that most apps use Android X for UI tests.

Fixes #1382
pyricau added a commit that referenced this issue Jul 3, 2019
This makes the assumption that most apps use Android X for UI tests.

Fixes #1382
pyricau added a commit that referenced this issue Jul 3, 2019
This makes the assumption that most apps use Android X for UI tests.

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

Successfully merging a pull request may close this issue.

1 participant