to top
public class

InstrumentationTest

extends Object
implements IDeviceTest IResumableTest
java.lang.Object
   ↳ com.android.tradefed.testtype.InstrumentationTest
Known Direct Subclasses

Class Overview

A Test that runs an instrumentation test package on given device.

Summary

Constants
String DELAY_MSEC_ARG
Public Constructors
InstrumentationTest()
Public Methods
void addInstrumentationArg(String key, String value)
Add an argument to provide when running the instrumentation tests
String getCoverageTarget()
Get the coverageTarget previously set via setCoverageTarget(String).
ITestDevice getDevice()
Get the device under test.
String getForceAbi()
String getPackageName()
Get the Android manifest package to run.
String getRunName()
Get the custom test run name that will be provided to listener
String getRunnerName()
Gets the Android instrumentation runner to be used.
boolean isResumable()
void run(ITestInvocationListener listener)
Runs the tests, and reports result to the listener.
void setBugreportFrequency(BugreportCollector.Freq freq)
Set the frequency with which to automatically collect bugreports after test failures.
void setClassName(String testClassName)
Optionally, set the test class name to run.
void setCollectsTestsShellTimeout(int timeout)
Set the max time in ms to allow for the 'max time to shell output response' when collecting tests.
void setCoverageTarget(String coverageTarget)
Set the coverage target of this test.
void setDevice(ITestDevice device)
Inject the device under test.
void setForceAbi(String abi)
Sets force-abi option.
void setInstallFile(File installFile)
Set the optional file to install that contains the tests.
void setLogcatOnFailure(boolean logcatOnFailure)
void setLogcatOnFailureSize(int logcatOnFailureSize)
void setMethodName(String testMethodName)
Optionally, set the test method to run.
void setPackageName(String packageName)
Set the Android manifest package to run.
void setReRunUsingTestFile(boolean reRunUsingTestFile)
void setRerunMode(boolean rerun)
Optionally, set the rerun mode.
void setResumeMode(boolean resume)
Optionally, set the resume mode.
void setRunName(String runName)
Set the custom test run name that will be provided to listener
void setRunnerName(String runnerName)
Optionally, set the Android instrumentation runner to use.
void setScreenshotOnFailure(boolean screenshotOnFailure)
void setTestFilePathOnDevice(String testFilePathOnDevice)
Optionally, set the path to a file located on the device that should contain a list of line separated test classes and methods (format: com.foo.Class#method) to be run.
void setTestPackageName(String testPackageName)
Sets the test package filter.
void setTestSize(String size)
Optionally, set the test size to run.
void setTestTimeout(int timeout)
Optionally, set the maximum time for each test.
void setTestsToRun(Collection<TestIdentifier> tests, boolean forceBatchMode)
Set the collection of tests that should be executed by this InstrumentationTest.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.testtype.IDeviceTest
From interface com.android.tradefed.testtype.IResumableTest
From interface com.android.tradefed.testtype.IRemoteTest

Constants

static final String DELAY_MSEC_ARG

Constant Value: "delay_msec"

Public Constructors

public InstrumentationTest ()

Public Methods

public void addInstrumentationArg (String key, String value)

Add an argument to provide when running the instrumentation tests

Parameters
key the argument name
value the argument value

public String getCoverageTarget ()

Get the coverageTarget previously set via setCoverageTarget(String).

public ITestDevice getDevice ()

Get the device under test.

Returns

public String getForceAbi ()

public String getPackageName ()

Get the Android manifest package to run.

public String getRunName ()

Get the custom test run name that will be provided to listener

public String getRunnerName ()

Gets the Android instrumentation runner to be used.

public boolean isResumable ()

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener the ITestInvocationListener of test results

public void setBugreportFrequency (BugreportCollector.Freq freq)

Set the frequency with which to automatically collect bugreports after test failures.

Note that there is _no feedback mechanism_ between the test runner and the bugreport collector, so use the EACH setting with due caution: if a large quantity of failures happen in rapid succession, the bugreport for a given one of the failures could end up being collected tens of minutes or hours after the respective failure occurred.

public void setClassName (String testClassName)

Optionally, set the test class name to run.

public void setCollectsTestsShellTimeout (int timeout)

Set the max time in ms to allow for the 'max time to shell output response' when collecting tests.

Exposed for testing.

public void setCoverageTarget (String coverageTarget)

Set the coverage target of this test.

Currently unused. This method is just present so coverageTarget can be later retrieved via getCoverageTarget()

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device the ITestDevice to use

public void setForceAbi (String abi)

Sets force-abi option.

public void setInstallFile (File installFile)

Set the optional file to install that contains the tests.

Parameters
installFile the installable File

public void setLogcatOnFailure (boolean logcatOnFailure)

public void setLogcatOnFailureSize (int logcatOnFailureSize)

public void setMethodName (String testMethodName)

Optionally, set the test method to run.

public void setPackageName (String packageName)

Set the Android manifest package to run.

public void setReRunUsingTestFile (boolean reRunUsingTestFile)

public void setRerunMode (boolean rerun)

Optionally, set the rerun mode.

public void setResumeMode (boolean resume)

Optionally, set the resume mode.

public void setRunName (String runName)

Set the custom test run name that will be provided to listener

public void setRunnerName (String runnerName)

Optionally, set the Android instrumentation runner to use.

public void setScreenshotOnFailure (boolean screenshotOnFailure)

public void setTestFilePathOnDevice (String testFilePathOnDevice)

Optionally, set the path to a file located on the device that should contain a list of line separated test classes and methods (format: com.foo.Class#method) to be run. If set, will automatically attempt to re-run tests using this test file via InstrumentationFileTest instead of executing separate adb commands for each remaining test via InstrumentationSerialTest"

public void setTestPackageName (String testPackageName)

Sets the test package filter.

If non-null, only tests within the given java package will be executed.

Will be ignored if a non-null value has been provided to setClassName(String)

public void setTestSize (String size)

Optionally, set the test size to run.

public void setTestTimeout (int timeout)

Optionally, set the maximum time for each test.

public void setTestsToRun (Collection<TestIdentifier> tests, boolean forceBatchMode)

Set the collection of tests that should be executed by this InstrumentationTest.

Parameters
tests the tests to run
forceBatchMode if true, the first attempt to run the tests will proceed as normal with the InstrumentationTest attempting to run all tests in the package. If false, the given tests will be run one by one with separate adb commands.