Package com.android.ddmlib.testrunner
Class InstrumentationResultParser
- java.lang.Object
-
- com.android.ddmlib.MultiLineReceiver
-
- com.android.ddmlib.testrunner.InstrumentationResultParser
-
- All Implemented Interfaces:
IShellOutputReceiver
public class InstrumentationResultParser extends MultiLineReceiver
Parses the 'raw output mode' results of an instrumentation test run from shell and informs a ITestRunListener of the results.Expects the following output:
If fatal error occurred when attempted to run the tests:
INSTRUMENTATION_STATUS: Error=error Message INSTRUMENTATION_FAILED:
or
INSTRUMENTATION_RESULT: shortMsg=error Message
Otherwise, expect a series of test results, each one containing a set of status key/value pairs, delimited by a start(1)/pass(0)/fail(-2)/error(-1) status code result. At end of test run, expects that the elapsed test time in seconds will be displayed
For example:
INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_STATUS: class=com.foo.FooTest INSTRUMENTATION_STATUS: test=testFoo INSTRUMENTATION_STATUS: numtests=2 INSTRUMENTATION_STATUS: stack=com.foo.FooTest#testFoo:312 com.foo.X INSTRUMENTATION_STATUS_CODE: -2 ... Time: X
Note that the "value" portion of the key-value pair may wrap over several text lines
-
-
Constructor Summary
Constructors Constructor Description InstrumentationResultParser(java.lang.String runName, ITestRunListener listener)
Creates the InstrumentationResultParser for a single listener.InstrumentationResultParser(java.lang.String runName, java.util.Collection<ITestRunListener> listeners)
Creates the InstrumentationResultParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Requests cancellation of test run.void
done()
Called by parent when adb session is complete.void
handleTestRunFailed(java.lang.String errorMsg)
Inform the parser of a instrumentation run failure.boolean
isCancelled()
Returns true if test run canceled.void
processNewLines(java.lang.String[] lines)
Processes the instrumentation test output from shell.-
Methods inherited from class com.android.ddmlib.MultiLineReceiver
addOutput, flush, setTrimLine
-
-
-
-
Constructor Detail
-
InstrumentationResultParser
public InstrumentationResultParser(java.lang.String runName, java.util.Collection<ITestRunListener> listeners)
Creates the InstrumentationResultParser.- Parameters:
runName
- the test run name to provide toITestRunListener.testRunStarted(String, int)
listeners
- informed of test results as the tests are executing
-
InstrumentationResultParser
public InstrumentationResultParser(java.lang.String runName, ITestRunListener listener)
Creates the InstrumentationResultParser for a single listener.- Parameters:
runName
- the test run name to provide toITestRunListener.testRunStarted(String, int)
listener
- informed of test results as the tests are executing
-
-
Method Detail
-
processNewLines
public void processNewLines(java.lang.String[] lines)
Processes the instrumentation test output from shell.- Specified by:
processNewLines
in classMultiLineReceiver
- Parameters:
lines
- The array containing the new lines.- See Also:
MultiLineReceiver.processNewLines(java.lang.String[])
-
isCancelled
public boolean isCancelled()
Returns true if test run canceled.- Returns:
- true to cancel the execution of the command.
- See Also:
IShellOutputReceiver.isCancelled()
-
cancel
public void cancel()
Requests cancellation of test run.
-
handleTestRunFailed
public void handleTestRunFailed(java.lang.String errorMsg)
Inform the parser of a instrumentation run failure. Should be called when the adb command used to run the test fails.
-
done
public void done()
Called by parent when adb session is complete.- Overrides:
done
in classMultiLineReceiver
-
-