Exemple #1
0
  private void createLogOnError(Class<?> testClass, String method, Throwable error) {
    Path shortLog =
        Paths.get(
            WorkFolder.Screenshots.getPath().toString(), CommonUtils.getCurrentDate() + ".log");
    try {
      BufferedWriter writer = Files.newBufferedWriter(shortLog, Charset.defaultCharset());
      StackTraceElement[] stackTrace = error.getStackTrace();
      writer.write(error.getMessage() + "\n");
      for (int i = 0; i < stackTrace.length; i++) {
        writer.write(stackTrace[i].toString() + "\n\t");
      }
      writer.close();
      TestCase test = new TestCase(testClass.getName());
      test.setShortLog(shortLog.toString());

      // Update test status
      TestArtifactManager.getInstance().getThisTestRun().setTestStatus(STATUS.Failed);
      TestArtifactManager.updateTestRunInfo(test);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemple #2
0
 public TCReport(TestCase tc) {
   this.testGUID = tc.getTestGUID();
   if (tc.getImages() != null)
     for (String img : tc.getImages()) {
       this.images = (this.images != null ? this.images + "," : "") + prefix + img;
     }
   this.qtName = (tc.getQtName() == null ? tc.getTestGUID() : tc.getQtName());
   this.exceptionImage = (tc.getExceptionImage() != null ? prefix + tc.getExceptionImage() : null);
   this.fullLog = (tc.getFullLog() != null ? prefix + tc.getFullLog() : null);
   this.shortLog = (tc.getShortLog() != null ? prefix + tc.getShortLog() : null);
   this.cookies = (tc.getCookies() != null ? prefix + tc.getCookies() : null);
   this.testStatus = STATUS.valueOf(tc.getTestStatus().toString());
   if (tc.getStopped() != null && tc.getStarted() != null) {
     this.duration = tc.getStopped().getTime() - tc.getStarted().getTime();
   }
 }