コード例 #1
0
 @Override
 public void onTestFailure(ITestResult iTestResult) {
   if (suiteName.toLowerCase().contains("webui")) {
     if (testInvocationCounter < maxCount) {
       testInvocationCounter++;
       iTestResult.setAttribute("retry", true);
     } else {
       LogUtils.log("Number of retries expired.");
       iTestResult.setStatus(ITestResult.FAILURE);
       // reset count
       testInvocationCounter = 1;
       testMethodName = TestNGUtils.constructTestMethodName(iTestResult);
       LogUtils.log("Test Failed: " + testMethodName, iTestResult.getThrowable());
       File testFolder = DumpUtils.createTestFolder(testMethodName, suiteName);
       write2LogFile(iTestResult, testFolder);
       write2ErrorTxtFile(iTestResult, testFolder);
     }
   } else {
     testMethodName = TestNGUtils.constructTestMethodName(iTestResult);
     LogUtils.log("Test Failed: " + testMethodName, iTestResult.getThrowable());
     File testFolder = DumpUtils.createTestFolder(testMethodName, suiteName);
     write2LogFile(iTestResult, testFolder);
     write2ErrorTxtFile(iTestResult, testFolder);
   }
   super.onTestFailure(iTestResult);
 }
コード例 #2
0
  @Override
  public void onConfigurationFailure(ITestResult iTestResult) {
    super.onConfigurationFailure(iTestResult);
    String testName = iTestResult.getTestClass().getName();
    String configurationName = iTestResult.getMethod().toString().split("\\(|\\)")[0];
    if (!enableLogstash && isAfter(iTestResult)) {
      DumpUtils.copyBeforeConfigurationsLogToTestDir(testName, suiteName);
      testName = testMethodName;
    }
    if (suiteName
        == null) { // this is in case the suite has a @BeforeSuite method. which is invoked before
                   // the onStart is.
      suiteName = System.getProperty("iTests.suiteName", "sgtest");
    }
    LogUtils.log("Configuration Failed: " + configurationName, iTestResult.getThrowable());

    if (enableLogstash && iTestResult.getMethod().isBeforeClassConfiguration()) {
      initLogstash2(iTestResult);
    }

    String newmanTestFolder = System.getProperty("newman.test.path");
    if (newmanTestFolder != null) {
      File testFolder = new File(newmanTestFolder);
      ZipUtils.unzipArchive(testFolder);
      try {
        copyAllFilesToLogDir(testFolder, testFolder);
      } catch (IOException e) {
        LogUtils.log("Failed to copy all log files");
      }
    } else {
      ZipUtils.unzipArchive(testMethodName, suiteName);
    }

    if (enableLogstash
        && isAfter(iTestResult)
        && !iTestResult.getMethod().isAfterClassConfiguration()
        && !iTestResult.getMethod().isAfterSuiteConfiguration()) {
      testName = testMethodName;
    }
    File testFolder = DumpUtils.createTestFolder(testName, suiteName);
    write2LogFile(iTestResult, testFolder);
    write2ErrorTxtFile(iTestResult, testFolder);

    if (isAfter(iTestResult)) {
      if (enableLogstash) {
        if (process != null) {
          killLogstashAgent(1, logstashLogPath);
        }
        if (process2 != null && iTestResult.getMethod().isAfterClassConfiguration()) {
          killLogstashAgent(2, logstashLogPath2);
        }
      }
    }
  }
コード例 #3
0
 @Override
 public void onTestSkipped(ITestResult iTestResult) {
   super.onTestSkipped(iTestResult);
   testMethodName = TestNGUtils.constructTestMethodName(iTestResult);
   LogUtils.log("Test Skipped: " + testMethodName, iTestResult.getThrowable());
   write2LogFile(iTestResult, DumpUtils.createTestFolder(testMethodName, suiteName));
 }
コード例 #4
0
 @Override
 public void onTestSuccess(ITestResult iTestResult) {
   super.onTestSuccess(iTestResult);
   if (suiteName.toLowerCase().contains("webui")) {
     testInvocationCounter = 1;
   }
   testMethodName = TestNGUtils.constructTestMethodName(iTestResult);
   LogUtils.log("Test Passed: " + testMethodName);
   write2LogFile(iTestResult, DumpUtils.createTestFolder(testMethodName, suiteName));
 }