{% setvar book_path %}/reference/kotlin/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 functions

Unit

Adds the given properties.

String
getInputArg(argName: String)

Returns the value of a given argument name.

Map<StringString>

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

Map<StringSerializable>

Returns a map of all the output test properties.

InputStream
openInputFile(pathname: String)

Provides an InputStream to a test file dependency.

InputStream

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

OutputStream

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

OutputStream

Provides an OutputStream to a test output file.

OutputStream
openOutputFile(pathname: String, append: Boolean)

Provides an OutputStream to a test output file.

Public functions

addOutputProperties

fun addOutputProperties(properties: Map<StringSerializable>): Unit

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

fun getInputArg(argName: String): String

Returns the value of a given argument name.

Parameters
argName: String

the argument name. Should not be null.

getInputArgs

fun getInputArgs(): Map<StringString>

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

getOutputProperties

fun getOutputProperties(): Map<StringSerializable>

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

openInputFile

fun openInputFile(pathname: String): InputStream

Provides an InputStream to a test file dependency.

Parameters
pathname: String

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

Returns
InputStream

an InputStream to the given test file.

openInternalInputFile

fun openInternalInputFile(pathname: String): InputStream

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

Parameters
pathname: String

path to the internal file. Should not be null.

Returns
InputStream

an InputStream to the given test file.

openInternalOutputFile

fun openInternalOutputFile(pathname: String): OutputStream

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

Parameters
pathname: String

path to the internal file. Should not be null.

Returns
OutputStream

an OutputStream to the given output file.

openOutputFile

fun openOutputFile(pathname: String): OutputStream

Provides an OutputStream to a test output file.

Parameters
pathname: String

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

Returns
OutputStream

an OutputStream to the given output file.

openOutputFile

fun openOutputFile(pathname: String, append: Boolean): OutputStream

Provides an OutputStream to a test output file.

Parameters
pathname: String

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

append: Boolean

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.