-
Notifications
You must be signed in to change notification settings - Fork 4k
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
how to force opt out the leakCanary in the test with LeakCanary 2? #1552
Comments
Have you tried this: https://square.github.io/leakcanary/recipes/#disabling-leakcanary ? |
I guess you mean in the test code to call
is there a way to do it in gradle for disabling leakCanary for all tests? |
LeakCanary automatically disable itself if it detects the As you pasted above, you maybe be able to remove the dependency from the config:
|
As @pyricau mentioned above, leakcanary disabled heapdump automatically when it detects instrumentation. Further, the only way to find leaks is by explicitly attaching a listener to the instrumentation process, which could be done by adding : @lannyf77 Not sure what exactly you're looking for, could you elaborate ? |
We would like to disable leakcanary for all tests, and it could be done previously with the Currently I have to put in different implementation of something like below within different build flavor: for release:
for debug:
and in the test, do something like:
|
@lannyf77 can you confirm that you're running tests directly on Android devices, however you are not using espresso? What's the purpose of said tests? |
@pyricau we do run test on real devices and with espresso, also for several submodules they have tests without ui such as for database; data model; middle tier etc. We would like to be able to run some flavor of test without leakCanary running. |
Suggestion from @vRallev (based on our codebase) : we could look for |
As a user you can do this and it is fairly easy (plus it's useful for many things)
And then add leak canary to only debug builds. Your Espresso build will not even have Leak Canary to begin with. |
Thanks 🙏 . That's useful for people finding this issue. That being said, I want to automate this if possible so that LeakCanary keeps a minimal config and no one has to run into this. |
I know this is an old issue and the fix is good for making sure the heap dump and analysis are not being executed on test builds. @pyricau do you think it makes sense to add the tests detection logic to |
@hichamboushaba can you file a new issue with these details and a link to this issue? |
https://square.github.io/leakcanary/upgrading-to-leakcanary-2.0/
says now it does not have leakcanary-android-no-op but only:
in our app with 1.6.3 we have
and would like to not run leakCanary in the test
now with LeakCanary 2, how to force opt out the leakCanary for the test?
The text was updated successfully, but these errors were encountered: