@Override
  public void testStarted(TestIdentifier testIdentifier) {
    testRunCount++;
    getLog()
        .info(
            deviceLogLinePrefix
                + String.format(
                    "%1$s%1$sStart [%2$d/%3$d]: %4$s",
                    INDENT, testRunCount, testCount, testIdentifier.toString()));

    if (createReport) { // reset start time for each test run
      currentTestCaseStartTime = System.currentTimeMillis();
      currentTestCase = new Testsuite.Testcase();
      currentTestCase.setClassname(testIdentifier.getClassName());
      currentTestCase.setName(testIdentifier.getTestName());
    }
  }
  @Override
  public void testAssumptionFailure(TestIdentifier testIdentifier, String trace) {
    if (takeScreenshotOnFailure) {
      String suffix = "_failure";
      String filepath = testIdentifier.getTestName() + suffix + SCREENSHOT_SUFFIX;

      executeOnAdbShell("screencap -p " + screenshotsPathOnDevice + "/" + filepath);
      getLog().info(deviceLogLinePrefix + INDENT + INDENT + filepath + " saved.");
    }

    ++testFailureCount;

    getLog().info(deviceLogLinePrefix + INDENT + INDENT + testIdentifier.toString());
    getLog().info(deviceLogLinePrefix + INDENT + INDENT + trace);

    if (createReport) {
      final Testsuite.Testcase.Failure failure = new Testsuite.Testcase.Failure();
      failure.setValue(trace);
      failure.setMessage(parseForMessage(trace));
      failure.setType(parseForException(trace));
      currentTestCase.getFailure().add(failure);
    }
  }
  @Override
  public void testEnded(TestIdentifier testIdentifier, Map<String, String> testMetrics) {
    getLog()
        .info(
            deviceLogLinePrefix
                + String.format(
                    "%1$s%1$sEnd [%2$d/%3$d]: %4$s",
                    INDENT, testRunCount, testCount, testIdentifier.toString()));
    logMetrics(testMetrics);

    if (createReport) {
      double seconds = (System.currentTimeMillis() - currentTestCaseStartTime) / 1000.0;
      currentTestCase.setTime(timeFormatter.format(seconds));
      report.getTestcase().add(currentTestCase);
    }
  }
Beispiel #4
0
 @Override
 public void testAssumptionFailure(TestIdentifier test, String trace) {
   mCurrentIssue = new Issue();
   mCurrentIssue.mTestName = test.toString();
   mCurrentIssue.mStackTrace = trace;
 }
  @Override
  public void testIgnored(TestIdentifier testIdentifier) {
    ++testIgnoredCount;

    getLog().info(deviceLogLinePrefix + INDENT + INDENT + testIdentifier.toString());
  }