PlatformTestStorageRegistry


public final class PlatformTestStorageRegistry


A registry instance that holds a reference to an PlatformTestStorage instance.

Users should use this to retrieve the appropriate PlatformTestStorage for the current execution environment.

Summary

Public methods

synchronized static PlatformTestStorage

Returns the registered PlatformTestStorage instance.

synchronized static void

Registers a new PlatformTestStorage instance.

Public methods

getInstance

synchronized public static PlatformTestStorage getInstance()

Returns the registered PlatformTestStorage instance.

By default, a FileTestStorage implementation is used. The default implementation is currently recommended for users using android gradle plugins version 8.0 or greater which supports writing output files (only). Gradle users using versions 8.0 or greater can optionally also opt in the test services TestStorage implementation by adding the following configuration to their build.gradle file: defaultConfig { testInstrumentationRunnerArguments useTestStorageService: "true" } dependencies { androidTestUtil "androidx.test.services:test-services:$servicesVersion" }

This method returns the instance last registered by the registerInstance method, or the default instance if none is ever registered. Advanced users can provide java.util.ServiceLoader metadata to provide an alternate implementation to load.

registerInstance

synchronized public static void registerInstance(PlatformTestStorage instance)

Registers a new PlatformTestStorage instance. This will override any previously set instance.

Users should not typically call this directly - it is intended for use by the test infrastructure.

Parameters
PlatformTestStorage instance

the instance to be registered. Cannot be null.