コード例 #1
0
  @Override
  protected void onFailure(ITestResult result) {
    super.onFailure(result);

    List<String> issueList = new LinkedList<String>();
    // IssueTracking issueTracking =
    // result.getMethod().getConstructorOrMethod().getMethod().getAnnotation(IssueTracking.class);
    IssueTracking issueTracking =
        result.getMethod().getConstructorOrMethod().getMethod().getAnnotation(IssueTracking.class);
    if (issueTracking != null) {
      issueList.addAll(asList(issueTracking.value()));
    }
    issueTracking =
        (IssueTracking) result.getMethod().getRealClass().getAnnotation(IssueTracking.class);
    if (issueTracking != null) {
      issueList.addAll(asList(issueTracking.value()));
    }

    if (!issueList.isEmpty()) {
      String issues = StringUtils.join(issueList, "\n");
      String filenameIdentification = getFilenameIdentification(result);
      File issueTrackingOutputFile =
          new File(failuresOutputDir, filenameIdentification + "/issues.txt");
      try {
        FileUtils.writeStringToFile(issueTrackingOutputFile, issues);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  }