/**
  * @param caseResult the case result
  * @return NOT_RUN in case it is skipped, PASSED if it passed, and FAILED otherwise
  */
 private ExecutionStatus getExecutionStatus(CaseResult caseResult) {
   if (caseResult.isSkipped()) {
     return ExecutionStatus.NOT_RUN;
   } else if (caseResult.isPassed()) {
     return ExecutionStatus.PASSED;
   } else {
     return ExecutionStatus.FAILED;
   }
 }
示例#2
0
 /** Recount my children. */
 @Override
 public void tally() {
   passCount = failCount = skipCount = 0;
   duration = 0;
   for (CaseResult r : cases) {
     r.setClass(this);
     if (r.isSkipped()) {
       skipCount++;
     } else if (r.isPassed()) {
       passCount++;
     } else {
       failCount++;
     }
     // retrieve the class duration from these cases' suite time
     if (duration == 0) {
       duration = r.getSuiteResult().getDuration();
     }
   }
 }
  /* (non-Javadoc)
   * @see hudson.plugins.testlink.result.ResultSeeker#seekAndUpdate(hudson.plugins.testlink.result.TestCaseWrapper<?>[], hudson.model.AbstractBuild, hudson.Launcher, hudson.model.BuildListener, hudson.plugins.testlink.TestLinkSite, hudson.plugins.testlink.result.Report)
   */
  @Override
  public void seek(
      TestCaseWrapper[] automatedTestCases,
      AbstractBuild<?, ?> build,
      Launcher launcher,
      BuildListener listener,
      TestLinkSite testlink)
      throws ResultSeekerException {
    listener.getLogger().println(Messages.Results_JUnit_LookingForTestCases()); // i18n
    try {
      final JUnitParser parser = new JUnitParser(false);
      final TestResult testResult = parser.parse(this.includePattern, build, launcher, listener);

      for (SuiteResult suiteResult : testResult.getSuites()) {
        for (CaseResult caseResult : suiteResult.getCases()) {
          for (TestCaseWrapper automatedTestCase : automatedTestCases) {
            final String[] commaSeparatedValues =
                automatedTestCase.getKeyCustomFieldValues(this.keyCustomField);
            for (String value : commaSeparatedValues) {
              if (!caseResult.isSkipped() && caseResult.getName().equals(value)) {
                ExecutionStatus status = this.getExecutionStatus(caseResult);
                automatedTestCase.addCustomFieldAndStatus(value, status);

                if (this.isIncludeNotes()) {
                  final String notes = this.getJUnitNotes(caseResult, build.number);
                  automatedTestCase.appendNotes(notes);
                }
                super.handleResult(automatedTestCase, build, listener, testlink, suiteResult);
              }
            }
          }
        }
      }
    } catch (IOException e) {
      throw new ResultSeekerException(e);
    } catch (InterruptedException e) {
      throw new ResultSeekerException(e);
    }
  }
    @Override
    public List<TestAction> getTestAction(TestObject testObject) {
      String id = testObject.getId();
      ClaimTestAction result = claims.get(id);

      // In Hudson 1.347 or so, IDs changed, and a junit/ prefix was added.
      // Attempt to fix this backward-incompatibility
      if (result == null && id.startsWith("junit")) {
        result = claims.get(id.substring(5));
      }

      if (result != null) {
        return Collections.<TestAction>singletonList(result);
      }

      if (testObject instanceof CaseResult) {
        CaseResult cr = (CaseResult) testObject;
        if (!cr.isPassed() && !cr.isSkipped()) {
          return Collections.<TestAction>singletonList(new ClaimTestAction(this, id));
        }
      }

      return Collections.emptyList();
    }