{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PlatformTestStorage

interface PlatformTestStorage

Known direct subclasses
FileTestStorage

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


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 @NonNull void

Adds the given properties.

abstract @NonNull String

Returns the value of a given argument name.

abstract @NonNull Map<@NonNull String, @NonNull String>

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

abstract @NonNull Map<@NonNull String, @NonNull Serializable>

Returns a map of all the output test properties.

abstract @NonNull InputStream

Provides an InputStream to a test file dependency.

abstract @NonNull InputStream

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

abstract @NonNull OutputStream

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

abstract @NonNull OutputStream

Provides an OutputStream to a test output file.

abstract @NonNull OutputStream
openOutputFile(@NonNull String pathname, @NonNull boolean append)

Provides an OutputStream to a test output file.

Public methods

addOutputProperties

@NonNull
public abstract void addOutputProperties(
    @NonNull Map<@NonNull String, @NonNull Serializable> 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

@NonNull
public abstract String getInputArg(@NonNull String argName)

Returns the value of a given argument name.

Parameters
@NonNull String argName

the argument name. Should not be null.

getInputArgs

@NonNull
public abstract Map<@NonNull String, @NonNull StringgetInputArgs()

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

getOutputProperties

@NonNull
public abstract Map<@NonNull String, @NonNull SerializablegetOutputProperties()

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

openInputFile

@NonNull
public abstract InputStream openInputFile(@NonNull String pathname)

Provides an InputStream to a test file dependency.

Parameters
@NonNull String pathname

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

Returns
InputStream

an InputStream to the given test file.

openInternalInputFile

@NonNull
public abstract InputStream openInternalInputFile(@NonNull String pathname)

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

Parameters
@NonNull String pathname

path to the internal file. Should not be null.

Returns
InputStream

an InputStream to the given test file.

openInternalOutputFile

@NonNull
public abstract OutputStream openInternalOutputFile(@NonNull String pathname)

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

Parameters
@NonNull String pathname

path to the internal file. Should not be null.

Returns
OutputStream

an OutputStream to the given output file.

openOutputFile

@NonNull
public abstract OutputStream openOutputFile(@NonNull String pathname)

Provides an OutputStream to a test output file.

Parameters
@NonNull String pathname

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

Returns
OutputStream

an OutputStream to the given output file.

openOutputFile

@NonNull
public abstract OutputStream openOutputFile(@NonNull String pathname, @NonNull boolean append)

Provides an OutputStream to a test output file.

Parameters
@NonNull String pathname

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

@NonNull 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.