Methods Summary |
---|
private void | addCommonStatus(java.lang.StringBuilder output)Adds common status results to the provided output.
addStatusKey(output, "stream", "\r\n" + CLASS_NAME);
addStatusKey(output, "test", TEST_NAME);
addStatusKey(output, "class", CLASS_NAME);
addStatusKey(output, "current", "1");
addStatusKey(output, "numtests", "1");
addStatusKey(output, "id", "InstrumentationTestRunner");
|
private void | addFailureCode(java.lang.StringBuilder outputBuilder)
addStatusCode(outputBuilder, "-2");
|
private void | addLineBreak(java.lang.StringBuilder outputBuilder)Append line break characters to output
outputBuilder.append("\r\n");
|
private void | addStackTrace(java.lang.StringBuilder output)Adds a stack trace status bundle to output.
addStatusKey(output, "stack", STACK_TRACE);
|
private void | addStartCode(java.lang.StringBuilder outputBuilder)
addStatusCode(outputBuilder, "1");
|
private void | addStatusCode(java.lang.StringBuilder outputBuilder, java.lang.String value)
outputBuilder.append("INSTRUMENTATION_STATUS_CODE: ");
outputBuilder.append(value);
addLineBreak(outputBuilder);
|
private void | addStatusKey(java.lang.StringBuilder outputBuilder, java.lang.String key, java.lang.String value)Helper method to add a status key-value bundle.
outputBuilder.append("INSTRUMENTATION_STATUS: ");
outputBuilder.append(key);
outputBuilder.append('=");
outputBuilder.append(value);
addLineBreak(outputBuilder);
|
private void | addSuccessCode(java.lang.StringBuilder outputBuilder)
addStatusCode(outputBuilder, "0");
|
private void | assertCommonAttributes()
assertEquals(CLASS_NAME, mTestResult.mSuiteName);
assertEquals(1, mTestResult.mTestCount);
assertEquals(TEST_NAME, mTestResult.mTestName);
|
private java.lang.StringBuilder | buildCommonResult()Builds a common test result using TEST_NAME and TEST_CLASS.
StringBuilder output = new StringBuilder();
// add test start bundle
addCommonStatus(output);
addStatusCode(output, "1");
// add end test bundle, without status
addCommonStatus(output);
return output;
|
private void | injectTestString(java.lang.String result)inject a test string into the result parser.
byte[] data = result.getBytes();
mParser.addOutput(data, 0, data.length);
mParser.flush();
|
protected void | setUp()
super.setUp();
mTestResult = new VerifyingTestResult();
mParser = new InstrumentationResultParser(mTestResult);
|
public void | testRunFailed()Test basic parsing of a test run failure.
StringBuilder output = new StringBuilder();
final String errorMessage = "Unable to find instrumentation info";
addStatusKey(output, "Error", errorMessage);
addStatusCode(output, "-1");
output.append("INSTRUMENTATION_FAILED: com.dummy/android.test.InstrumentationTestRunner");
addLineBreak(output);
injectTestString(output.toString());
assertEquals(errorMessage, mTestResult.mRunFailedMessage);
|
public void | testRunFailedResult()Test parsing of a test run failure, where an instrumentation component failed to load
Parsing input takes the from of INSTRUMENTATION_RESULT: fff
StringBuilder output = new StringBuilder();
final String errorMessage = "Unable to instantiate instrumentation";
output.append("INSTRUMENTATION_RESULT: shortMsg=");
output.append(errorMessage);
addLineBreak(output);
output.append("INSTRUMENTATION_CODE: 0");
addLineBreak(output);
injectTestString(output.toString());
assertEquals(errorMessage, mTestResult.mRunFailedMessage);
|
public void | testTestFailed()Test basic parsing of failed test case.
StringBuilder output = buildCommonResult();
addStartCode(output);
addCommonStatus(output);
addStackTrace(output);
addFailureCode(output);
injectTestString(output.toString());
assertCommonAttributes();
assertEquals(1, mTestResult.mNumTestsRun);
assertEquals(ITestRunListener.TestFailure.FAILURE, mTestResult.mTestStatus);
assertEquals(STACK_TRACE, mTestResult.mTrace);
|
public void | testTestStarted()Tests that the test run started and test start events is sent on first
bundle received.
StringBuilder output = buildCommonResult();
addStartCode(output);
injectTestString(output.toString());
assertCommonAttributes();
assertEquals(0, mTestResult.mNumTestsRun);
|
public void | testTestSuccess()Tests that a single successful test execution.
StringBuilder output = buildCommonResult();
addStartCode(output);
addCommonStatus(output);
addSuccessCode(output);
injectTestString(output.toString());
assertCommonAttributes();
assertEquals(1, mTestResult.mNumTestsRun);
assertEquals(null, mTestResult.mTestStatus);
|
public void | testTimeParsing()Test basic parsing and conversion of time from output.
final String timeString = "Time: 4.9";
injectTestString(timeString);
assertEquals(4900, mTestResult.mTestTime);
|