问题
when I run my instrumentation tests against the debug version of my app, leak canary will block the UI thread and cause the instrumentation test to fail. I had to revert to the old version. Is there any way to avoid the leakcanary UI or companion app (not sure what is blocking the UI thread) from running, while running the instrumentation tests?
Thanks
回答1:
See the doc: https://square.github.io/leakcanary/recipes/#running-leakcanary-in-instrumentation-tests
LeakCanary automatically disables itself by setting LeakCanary.config.dumpHeap to false if it detects classes from the androidx.test dependency in the runtime classpath. If you run UI tests without androidx.test, we strongly advise that you set dumpHeap to false: LeakCanary.config = LeakCanary.config.copy(dumpHeap = false).
来源:https://stackoverflow.com/questions/57915748/leakcanary-2-0-blocking-the-main-thread-causes-my-instrumentation-tests-to-fai