InstrumentationRegistry
class InstrumentationRegistry
An exposed registry instance that holds a reference to the instrumentation running in the process and its arguments.
Instrumentation and InstrumentationRegistry are low level APIs, typically used by higher level test frameworks. It is generally not recommended for direct use by most tests.
Summary
Public functions |
|
---|---|
Bundle |
Returns a copy of instrumentation arguments Bundle. |
Instrumentation |
Returns the instrumentation currently running. |
Unit |
registerInstance(instrumentation: Instrumentation, arguments: Bundle) Records/exposes the instrumentation currently running and stores a copy of the instrumentation arguments Bundle in the registry. |
Public functions
getArguments
fun getArguments(): Bundle
Returns a copy of instrumentation arguments Bundle. Use this to get a Bundle containing the command line arguments passed to Instrumentation into your test.
This Bundle is not guaranteed to be present under all instrumentations.
Returns | |
---|---|
Bundle |
Bundle the arguments for this instrumentation. |
Throws | |
---|---|
java.lang.IllegalStateException |
if no argument Bundle has been registered. |
getInstrumentation
fun getInstrumentation(): Instrumentation
Returns the instrumentation currently running. Use this to get an Instrumentation into your test.
Throws | |
---|---|
java.lang.IllegalStateException |
if instrumentation hasn't been registered |
registerInstance
fun registerInstance(instrumentation: Instrumentation, arguments: Bundle): Unit
Records/exposes the instrumentation currently running and stores a copy of the instrumentation arguments Bundle in the registry.
This is a global registry - so be aware of the impact of calling this method!
Parameters | |
---|---|
instrumentation: Instrumentation |
the instrumentation currently running. |
arguments: Bundle |
the arguments for this application. Null deregisters any existing arguments. |