예제 #1
0
  /**
   * Summarize the last test results from the passed set of jobs, including the packages of the job.
   * If a job doesn't include any tests, add a 0 summary.
   *
   * @param jobs
   * @return
   */
  public static TestResultSummary getDetailedTestResultSummary(Collection<TopLevelItem> jobs) {
    TestResultSummary summary = new TestResultSummary();

    for (TopLevelItem item : jobs) {
      if (item instanceof Job) {
        Job job = (Job) item;

        // create summary for the last run
        Run run = job.getLastBuild();
        if (run != null) {
          TestResult testResult = TestUtil.getTestResult(job.getLastBuild());
          summary.addTestResult(testResult);

          AbstractTestResultAction tra = run.getAction(AbstractTestResultAction.class);

          if (tra != null) {
            if (tra.getResult() instanceof MetaTabulatedResult) {
              MetaTabulatedResult result = (MetaTabulatedResult) tra.getResult();

              // add test results for the packages
              for (hudson.tasks.test.TestResult child : result.getChildren()) {
                PackageResult sub =
                    new PackageResult(
                        child, child.getTotalCount(), child.getFailCount(), child.getSkipCount());
                testResult.getPackageResults().add(sub);
              }
            }
          }
        }
      }
    }

    return summary;
  }
 private int getTestAge(TestResult result) {
   if (result.isPassed()) return 0;
   else if (result.getOwner() != null) {
     return result.getOwner().getNumber() - result.getFailedSince() + 1;
   } else {
     return 0;
   }
 }
  private int outputTest(
      StringBuilder buffer,
      TestResult failedTest,
      boolean showStack,
      boolean showMessage,
      int lengthLeft) {
    StringBuilder local = new StringBuilder();

    local.append(failedTest.isPassed() ? "PASSED" : "FAILED");
    local.append(":  ");

    if (failedTest instanceof CaseResult) {
      local.append(((CaseResult) failedTest).getClassName());
    } else {
      local.append(failedTest.getFullName());
    }
    local.append(".");

    local.append(failedTest.getDisplayName());
    local.append("\n");

    if (showMessage) {
      local.append("\n");
      local.append("Error Message:\n");
      local.append(failedTest.getErrorDetails());
      local.append("\n");
    }

    if (showStack) {
      local.append("\n");
      local.append("Stack Trace:\n");
      local.append(failedTest.getErrorStackTrace());
      local.append("\n");
    }

    if (showMessage || showStack) {
      local.append("\n");
    }

    if (local.length() > lengthLeft) {
      local.setLength(lengthLeft);
    }

    buffer.append(local.toString());
    return local.length();
  }
예제 #4
0
 @Override
 public String getTestResultPath(TestResult it) {
   // Prepend Configuration path
   return it.getOwner().getParent().getShortUrl() + super.getTestResultPath(it);
 }