Disable LeakCanary for given tests / test classes

1.1k views Asked by At

I have added LeakCanary2 to instrument test by simply adding it to the gradle file.

It works great but it enables LeakCanary for all my tests, which is time consuming. Is there a way that I can only enable LeakCanary for a small set of tests / test classes?

1

There are 1 answers

4
Pierre-Yves Ricau On

You can use FailAnnotatedTestOnLeakRunListener instead of FailTestOnLeakRunListener:

A JUnit RunListener extending FailTestOnLeakRunListener to detecting memory leaks in Android instrumentation tests only when the @FailTestOnLeak annotation is used.