public String getFullName() {
   return testInfo.getModuleName()
       + '.'
       + testInfo.getPackageName()
       + '.'
       + testInfo.getClassName()
       + '.'
       + testInfo.getCaseName();
 }
  @Exported(name = "status", visibility = 9)
  // because stapler notices suffix 's' and remove it
  public Status getStatus() {
    if (isSkipped()) {
      return Status.SKIPPED;
    }
    JUnitTestInfo junitTestInfo = getPreviousTestInfo();
    if (junitTestInfo == null) {
      return isPassed() ? Status.PASSED : Status.FAILED;
    }

    if (junitTestInfo.getStatus() == JUnitTestInfo.STATUS_SUCCESS) {
      return isPassed() ? Status.PASSED : Status.REGRESSION;
    } else {
      return isPassed() ? Status.FIXED : Status.FAILED;
    }
  }
 /**
  * Gets the number of consecutive builds (including this) that this test case has been failing.
  */
 @Exported(visibility = 9)
 public int getAge() {
   if (isPassed()) {
     return 0;
   } else {
     return testInfo.getBuildNumber() - getFailedSince() + 1;
   }
 }
 /** If this test failed, then return the build number when this test started failing. */
 @Override
 @Exported(visibility = 9)
 public int getFailedSince() {
   // If we haven't calculated failedSince yet, and we should,
   // do it now.
   if (failedSince == 0 && getFailCount() > 0) {
     try {
       List<JUnitSummaryInfo> history =
           junitDB.summarizeTestCaseHistory(
               testInfo.getProjectName(),
               testInfo.getModuleName(),
               testInfo.getPackageName(),
               testInfo.getClassName(),
               testInfo.getCaseName(),
               5000);
       for (JUnitSummaryInfo junitSummaryInfo : history) {
         int failedBuildNumber = junitSummaryInfo.getBuildNumber();
         if (failedBuildNumber < testInfo.getBuildNumber()
             && (junitSummaryInfo.getFailCount() > 0 || junitSummaryInfo.getErrorCount() > 0)) {
           failedSince = failedBuildNumber;
           break;
         }
       }
       if (failedSince == 0) {
         failedSince = testInfo.getBuildNumber();
       }
     } catch (SQLException sE) {
       LOGGER.log(Level.SEVERE, sE.getMessage(), sE);
     }
   }
   return failedSince;
 }
  /**
   * The stderr of this test.
   *
   * @see #getStdout()
   * @since 1.294
   */
  @Override
  @Exported
  public String getStderr() {
    StringReaderWriter stderrReaderWriter = new StringReaderWriter();
    String result = "";
    try {
      JUnitTestDetailInfo junitTestDetailInfo =
          junitDB.readTestDetail(
              testInfo.getBuildNumber(),
              testInfo.getProjectName(),
              testInfo.getModuleName(),
              testInfo.getPackageName(),
              testInfo.getClassName(),
              testInfo.getCaseName(),
              null,
              stderrReaderWriter);
      StringWriter sW = new StringWriter();
      IOUtil.write(junitTestDetailInfo.getStderr(), sW);
      result = sW.toString();
      if (result == null || result.isEmpty()) {
        junitTestDetailInfo =
            junitDB.readTestDetail(
                testInfo.getBuildNumber(),
                testInfo.getProjectName(),
                testInfo.getModuleName(),
                "<init>",
                "<init>",
                "<init>",
                null,
                stderrReaderWriter);
        sW = new StringWriter();
        IOUtil.write(junitTestDetailInfo.getStderr(), sW);
        result = sW.toString();
      }
    } catch (SQLException sE) {
      LOGGER.log(Level.SEVERE, sE.getMessage(), sE);
    } catch (IOException iE) {
      LOGGER.log(Level.SEVERE, iE.getMessage(), iE);
    } finally {
      try {
        stderrReaderWriter.release();
      } catch (IOException iE) {
        LOGGER.log(Level.SEVERE, iE.getMessage(), iE);
      }
    }

    return result;
  }
 private JUnitTestInfo getPreviousTestInfo() {
   if (previousTestInfo == null) {
     try {
       previousTestInfo =
           junitDB.queryTestCaseForBuildPriorTo(
               testInfo.getProjectName(),
               testInfo.getBuildNumber(),
               testInfo.getModuleName(),
               testInfo.getPackageName(),
               testInfo.getClassName(),
               testInfo.getCaseName());
     } catch (SQLException sE) {
       LOGGER.log(Level.SEVERE, sE.getMessage(), sE);
     }
   }
   return previousTestInfo;
 }
 public JUnitMetricsInfo getMetrics() {
   if (metrics == null) {
     try {
       metrics =
           junitDB.fetchTestCaseMetrics(
               testInfo.getBuildNumber(),
               testInfo.getProjectName(),
               testInfo.getModuleName(),
               testInfo.getPackageName(),
               testInfo.getClassName(),
               testInfo.getCaseName());
     } catch (SQLException sE) {
       LOGGER.log(Level.SEVERE, sE.getMessage(), sE);
     }
   }
   return metrics;
 }
 /** If there was an error or a failure, this is the text from the message. */
 @Override
 @Exported
 public String getErrorDetails() {
   String result = null;
   try {
     JUnitTestDetailInfo junitTestDetailInfo =
         junitDB.readTestDetail(
             testInfo.getBuildNumber(),
             testInfo.getProjectName(),
             testInfo.getModuleName(),
             testInfo.getPackageName(),
             testInfo.getClassName(),
             testInfo.getCaseName(),
             null,
             null);
     result = junitTestDetailInfo.getErrorMessage();
   } catch (SQLException sE) {
     LOGGER.log(Level.SEVERE, sE.getMessage(), sE);
   } catch (IOException iE) {
     LOGGER.log(Level.SEVERE, iE.getMessage(), iE);
   }
   return result;
 }
 /**
  * Tests whether the test was skipped or not. TestNG allows tests to be skipped if their
  * dependencies fail or they are part of a group that has been configured to be skipped.
  *
  * @return true if the test was not executed, false otherwise.
  */
 @Exported(visibility = 9)
 public boolean isSkipped() {
   return testInfo.getStatus() == JUnitTestInfo.STATUS_SKIP;
 }
 /** @return true if the test was not skipped and did not fail, false otherwise. */
 @Override
 public boolean isPassed() {
   return testInfo.getStatus() == JUnitTestInfo.STATUS_SUCCESS;
 }
 /** Gets the duration of the test, in seconds */
 @Override
 @Exported(visibility = 9)
 public float getDuration() {
   return (float) testInfo.getDuration() / 1000;
 }
 /**
  * Gets the name of the test, which is returned from {@code TestCase.getName()}
  *
  * <p>Note that this may contain any URL-unfriendly character.
  */
 @Exported(visibility = 999)
 public @Override String getName() {
   return testInfo.getCaseName();
 }
 public String getDisplayName() {
   return testInfo.getCaseName();
 }