android-components / mozilla.components.support.android.test.leaks / LeakDetectionRule

LeakDetectionRule

class LeakDetectionRule : MethodRule (source)

JUnit rule that will install LeakCanary to detect memory leaks happening while the instrumented tests are running.

If a leak is found the test will fail and the test report will contain information about the leak.

Note that additionally to adding this rule you need to add the following instrumentation argument:

android {
  defaultConfig {
    // ...

    testInstrumentationRunnerArgument "listener", "com.squareup.leakcanary.FailTestOnLeakRunListener"
   }
 }

Constructors

Name Summary
<init> LeakDetectionRule()
JUnit rule that will install LeakCanary to detect memory leaks happening while the instrumented tests are running.

Functions

Name Summary
apply fun apply(base: Statement, method: FrameworkMethod, target: Any): Statement

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.