GranularRetriableTestWrapper

public class GranularRetriableTestWrapper
extends Object implements IRemoteTest

java.lang.Object
   ↳ com.android.tradefed.testtype.GranularRetriableTestWrapper


A wrapper class that works on the IRemoteTest to gather and retry on failed test cases up to X times.

Note:

  • The prerequisite to run a subset of test cases is that the test type should implement the interface ITestFilterReceiver.
  • X is customized max retry number.

Summary

Public constructors

GranularRetriableTestWrapper(IRemoteTest test, TestFailureListener failureListener, List<ITestInvocationListener> moduleLevelListeners)

Public methods

List<TestRunResult> getFinalTestRunResults()

Get the merged TestRunResults from each IRemoteTest run.

int getNumIndividualTests()

Calculate the number of testcases in the IRemoteTest.

boolean hasFailed()

Check if any testRunResult has ever failed.

void run(ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void run(ITestInvocationListener listener, int maxNumRun)

Schedule a series of IRemoteTest "run".

void setInvocationContext(IInvocationContext moduleInvocationContext)

Set the IInvocationContext as a GranularRetriableTestWrapper attribute.

void setLogSaver(ILogSaver logSaver)

Set the Module's ILogSaver as a GranularRetriableTestWrapper attribute.

void setMarkTestsSkipped(boolean skipTestCases)

Set the ModuleDefinition RunStrategy as a GranularRetriableTestWrapper attribute.

void setMetricCollectors(List<IMetricCollector> runMetricCollectors)

Set the ModuleDefinition's runMetricCollector as a GranularRetriableTestWrapper attribute.

void setModuleConfig(IConfiguration moduleConfiguration)

Set the ModuleDefinition's ModuleConfig as a GranularRetriableTestWrapper attribute.

void setModuleId(String moduleId)

Set the ModuleDefinition name as a GranularRetriableTestWrapper attribute.

Public constructors

GranularRetriableTestWrapper

public GranularRetriableTestWrapper (IRemoteTest test, 
                TestFailureListener failureListener, 
                List<ITestInvocationListener> moduleLevelListeners)

Parameters
test IRemoteTest

failureListener TestFailureListener

moduleLevelListeners List

Public methods

getFinalTestRunResults

public List<TestRunResult> getFinalTestRunResults ()

Get the merged TestRunResults from each IRemoteTest run. TODO: Merge TestRunResults when ag/3893676 is submitted.

Returns
List<TestRunResult>

getNumIndividualTests

public int getNumIndividualTests ()

Calculate the number of testcases in the IRemoteTest. This value distincts the same testcases that are rescheduled multiple times.

Returns
int

hasFailed

public boolean hasFailed ()

Check if any testRunResult has ever failed.

Returns
boolean

run

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results

Throws
DeviceNotAvailableException

run

public void run (ITestInvocationListener listener, 
                int maxNumRun)

Schedule a series of IRemoteTest "run". TODO: Customize the retry strategy; Each run is granularized to a subset of the whole testcases.

Parameters
listener ITestInvocationListener: The ResultForwarder listener which contains a new moduleListener for each run.

maxNumRun int: The max number of retries to schedule for the same IRemoteTest.

Throws
DeviceNotAvailableException

setInvocationContext

public void setInvocationContext (IInvocationContext moduleInvocationContext)

Set the IInvocationContext as a GranularRetriableTestWrapper attribute.

Parameters
moduleInvocationContext IInvocationContext: The wrapper uses the InvocationContext to initialize the MetricCollector when necessary.

setLogSaver

public void setLogSaver (ILogSaver logSaver)

Set the Module's ILogSaver as a GranularRetriableTestWrapper attribute.

Parameters
logSaver ILogSaver: The listeners for each test run should save the logs.

setMarkTestsSkipped

public void setMarkTestsSkipped (boolean skipTestCases)

Set the ModuleDefinition RunStrategy as a GranularRetriableTestWrapper attribute.

Parameters
skipTestCases boolean: whether the testcases should be skipped.

setMetricCollectors

public void setMetricCollectors (List<IMetricCollector> runMetricCollectors)

Set the ModuleDefinition's runMetricCollector as a GranularRetriableTestWrapper attribute.

Parameters
runMetricCollectors List: A list of MetricCollector for the module.

setModuleConfig

public void setModuleConfig (IConfiguration moduleConfiguration)

Set the ModuleDefinition's ModuleConfig as a GranularRetriableTestWrapper attribute.

Parameters
moduleConfiguration IConfiguration: Provide the module metrics.

setModuleId

public void setModuleId (String moduleId)

Set the ModuleDefinition name as a GranularRetriableTestWrapper attribute.

Parameters
moduleId String: the name of the moduleDefinition.