PlatformTestStorage


@ExperimentalTestApi
public interface PlatformTestStorage

Known direct subclasses
FileTestStorage

A class that reads/writes the runner data using the raw file system.

TestStorage

Provides convenient I/O operations for reading/writing testing relevant files, properties in a test.


An interface represents on-device I/O operations in an Android test.

This is a low level API, typically used by higher level test frameworks. It is generally not recommended for direct use by most tests.

Use a concrete implementation class of this interface if you need to read/write files in your tests. For example, in an Android Instrumentation test, use androidx.test.services.storage.TestStorage when the test services is installed on the device.

This API is experimental and is subject to change or removal in future releases.

Summary

Public methods

abstract void

Adds the given properties.

abstract String

Returns the value of a given argument name.

abstract Map<StringString>

Returns the name/value map of all test arguments or an empty map if no arguments are defined.

abstract Map<StringSerializable>

Returns a map of all the output test properties.

abstract InputStream

Provides an InputStream to a test file dependency.

abstract InputStream

Provides an InputStream to an internal file used by the testing infrastructure.

abstract OutputStream

Provides an OutputStream to an internal file used by the testing infrastructure.

abstract OutputStream

Provides an OutputStream to a test output file.

abstract OutputStream
openOutputFile(String pathname, boolean append)

Provides an OutputStream to a test output file.

Public methods

addOutputProperties

abstract void addOutputProperties(Map<StringSerializable> properties)

Adds the given properties.

Adding a property with the same name would append new values and overwrite the old values if keys already exist.

getInputArg

abstract String getInputArg(String argName)

Returns the value of a given argument name.

Parameters
String argName

the argument name. Should not be null.

getInputArgs

abstract Map<StringStringgetInputArgs()

Returns the name/value map of all test arguments or an empty map if no arguments are defined.

getOutputProperties

abstract Map<StringSerializablegetOutputProperties()

Returns a map of all the output test properties. If no properties exist, an empty map will be returned.

openInputFile

abstract InputStream openInputFile(String pathname)

Provides an InputStream to a test file dependency.

Parameters
String pathname

path to the test file dependency. Should not be null.

Returns
InputStream

an InputStream to the given test file.

openInternalInputFile

abstract InputStream openInternalInputFile(String pathname)

Provides an InputStream to an internal file used by the testing infrastructure.

Parameters
String pathname

path to the internal file. Should not be null.

Returns
InputStream

an InputStream to the given test file.

openInternalOutputFile

abstract OutputStream openInternalOutputFile(String pathname)

Provides an OutputStream to an internal file used by the testing infrastructure.

Parameters
String pathname

path to the internal file. Should not be null.

Returns
OutputStream

an OutputStream to the given output file.

openOutputFile

abstract OutputStream openOutputFile(String pathname)

Provides an OutputStream to a test output file.

Parameters
String pathname

path to the test output file. Should not be null.

Returns
OutputStream

an OutputStream to the given output file.

openOutputFile

abstract OutputStream openOutputFile(String pathname, boolean append)

Provides an OutputStream to a test output file.

Parameters
String pathname

path to the test output file. Should not be null.

boolean append

if true, then the lines will be added to the end of the file rather than overwriting.

Returns
OutputStream

an OutputStream to the given output file.