当前位置: 首页>>代码示例>>Java>>正文


Java Utils类代码示例

本文整理汇总了Java中org.testng.internal.Utils的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Utils类属于org.testng.internal包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateExceptionReport

import org.testng.internal.Utils; //导入依赖的package包/类
private void generateExceptionReport(Throwable exception, ITestNGMethod method, String title)
{
    m_out.println("<p>" + Utils.escapeHtml(title) + "</p>");
    StackTraceElement[] s1 = exception.getStackTrace();
    Throwable t2 = exception.getCause();
    if (t2 == exception)
    {
        t2 = null;
    }
    int maxlines = Math.min(100, StackTraceTools.getTestRoot(s1, method));
    for (int x = 0; x <= maxlines; x++)
    {
        m_out.println((x > 0 ? "<br/>at " : "") + Utils.escapeHtml(s1[x].toString()));
    }
    if (maxlines < s1.length)
    {
        m_out.println("<br/>" + (s1.length - maxlines) + " lines not shown");
    }
    if (t2 != null)
    {
        generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage());
    }
}
 
开发者ID:basavaraj1985,项目名称:DolphinNG,代码行数:24,代码来源:EmailableReporter.java

示例2: setFailedTcAttribute

import org.testng.internal.Utils; //导入依赖的package包/类
private void setFailedTcAttribute(XMLStringBuffer doc, ITestResult failedTestCase) {
    Properties attributesFailedTestSuites = new Properties();
    String tcName = ((HashMap<String, String>) failedTestCase.getParameters()[0]).get(PROP_TEST_ID);
    attributesFailedTestSuites.setProperty(XMLConstants.ATTR_NAME, tcName);
    long elapsedTimeMillis = failedTestCase.getEndMillis() - failedTestCase.getStartMillis();
    testRunningTotalTime += elapsedTimeMillis;
    Throwable t = failedTestCase.getThrowable();
    doc.push(XMLConstants.TESTCASE, attributesFailedTestSuites);
    if (t != null) {
        attributesFailedTestSuites.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName());
        String message = t.getMessage();
        if ((message != null) && (message.length() > 0)) {
            attributesFailedTestSuites.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE
        }
        doc.push(XMLConstants.FAILURE, attributesFailedTestSuites);
        doc.addCDATA(Utils.stackTrace(t, false)[0]);
        doc.pop();
    } else {
        doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR
    }
    doc.pop();
}
 
开发者ID:HotelsDotCom,项目名称:heat,代码行数:23,代码来源:CustomJUnitReportListener.java

示例3: createFailureElement

import org.testng.internal.Utils; //导入依赖的package包/类
public static void createFailureElement(XMLStringBuffer doc, ITestResult tr) {
  Properties attrs = new Properties();
  Throwable t = tr.getThrowable();
  if (t != null) {
    attrs.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName());
    String message= t.getMessage();
    if ((message != null) && (message.length() > 0)) {
      attrs.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE
    }
    doc.push(XMLConstants.FAILURE, attrs);
    doc.addCDATA(Utils.stackTrace(t, false)[0]);
    doc.pop();
  } else {
    doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR
  }
}
 
开发者ID:web-auto,项目名称:wtf-core,代码行数:17,代码来源:XmlJuintReport.java

示例4: retry

import org.testng.internal.Utils; //导入依赖的package包/类
/**
 * Print the test status while test retry.
 */
public boolean retry(ITestResult result) {
  Throwable throwable = result.getThrowable();

  String testClassName = String.format("%s.%s",
      result.getMethod().getRealClass().toString(), result.getMethod().getMethodName()).
          replace("class com.ebay.webdriver.", "..");

  if (throwable != null) {
    LOG(Level.SEVERE,
        "STACK TRACE: " + testClassName + "\n" + Utils.stackTrace(throwable, false)[0]);
  }

  if(count <= maxCount) {
    result.setAttribute("RETRY", new Integer(count));

    LOG(Level.WARNING, "[RETRYING] " + testClassName + " FAILED, " +
        "Retrying " + count + " times");

    count += 1;
    return true;
  }
  return false;
}
 
开发者ID:web-auto,项目名称:wtf-core,代码行数:27,代码来源:BaseTestRetryAnalyzer.java

示例5: GenericATEProblem

import org.testng.internal.Utils; //导入依赖的package包/类
/**
 * Instantiates a new generic ate problem.
 *
 * @param source
 *            the source
 * @param see
 *            the see
 */
public GenericATEProblem(Object source, Exception exception) {
	super(source, exception);
	String[] stackTraces = Utils.stackTrace(exception, false);
	String tmp1 = stackTraces[1];
	if (tmp1 == null)
		fullStackTrace = "fullstacktrace Internal error.";

	else
		fullStackTrace = tmp1;
	String tmp0 = stackTraces[0];
	if (tmp0 == null)
		shortStackTrace = "shortstacktrace Internal error.";
	else
		shortStackTrace = tmp0;
	final Level warn2 = Level.WARN;
	if (warn2 == null) {
		throw GlobalUtils.createInternalError("jvm");
	} else {
		this.loggingLevel = warn2;
	}
	if (exception instanceof IATEException) this.ateException = (IATEException) exception;
	this.fatalProblem = true;
	this.problemMessage = exception.getMessage();
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:33,代码来源:GenericATEProblem.java

示例6: generateExceptionReport

import org.testng.internal.Utils; //导入依赖的package包/类
private String generateExceptionReport(Throwable exception, ITestNGMethod method, String title)
{
    StackTraceElement[] s1 = exception.getStackTrace();
    Throwable t2 = exception.getCause();

    StringBuilder exceptionStackTrace = new StringBuilder();

    if (t2 == exception)
    {
        t2 = null;
    }
    int maxlines = Math.min(100, StackTraceTools.getTestRoot(s1, method));
    for (int x = 0; x <= maxlines; x++)
    {
        exceptionStackTrace.append((x > 0 ? "<br/>at " : "") + Utils.escapeHtml(s1[x].toString()));
    }
    if (maxlines < s1.length)
    {
        exceptionStackTrace.append("<br/>" + (s1.length - maxlines) + " lines not shown");
    }
    if (t2 != null)
    {
        generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage());
    }

    return exceptionStackTrace.toString();
}
 
开发者ID:pradeeptaswain,项目名称:oldmonk,代码行数:28,代码来源:ReporterAPI.java

示例7: flushSoftAsserts

import org.testng.internal.Utils; //导入依赖的package包/类
public void flushSoftAsserts() {
  LOG(Level.INFO, String.format("Found Soft Asserts(%s)", count()));
  for (Throwable throwable : softAssertList) {
    if (throwable != null) {
      LOG(Level.SEVERE, Utils.stackTrace(throwable, false)[0]);
    }
  }
  LOG(Level.INFO, "End of Soft Asserts..");
}
 
开发者ID:web-auto,项目名称:wtf-core,代码行数:10,代码来源:SoftAssert.java

示例8: createElement

import org.testng.internal.Utils; //导入依赖的package包/类
public static void createElement(XMLStringBuffer doc, ITestResult tr) {
  Properties attrs = new Properties();
  long elapsedTimeMillis = tr.getEndMillis() - tr.getStartMillis();
  String name =
      tr.getMethod().isTest() ? tr.getName() : Utils.detailedMethodName(tr.getMethod(), false);
      
  //SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMMMM hh:mm aaa");
  //String testRunTest = String.format("%s", simpleDateFormat.format(new Date()));

  String testRunTest = FastDateFormat.getInstance("dd-MMMMM hh:mm aaa").format(new Date());

  attrs.setProperty(XMLConstants.ATTR_NAME, String.format("%s  [%s]", name, testRunTest));
  attrs.setProperty(XMLConstants.ATTR_CLASSNAME, tr.getTestClass().getRealClass().getName());
  attrs.setProperty(XMLConstants.ATTR_TIME, "" + (((double) elapsedTimeMillis) / 1000));

  if((ITestResult.FAILURE == tr.getStatus()) || (ITestResult.SKIP == tr.getStatus())) {
    doc.push(XMLConstants.TESTCASE, attrs);

    if(ITestResult.FAILURE == tr.getStatus()) {
      createFailureElement(doc, tr);
    }
    else if(ITestResult.SKIP == tr.getStatus()) {
      createSkipElement(doc, tr);
    }
    doc.pop();
  }else {
    doc.addEmptyElement(XMLConstants.TESTCASE, attrs);
  }
}
 
开发者ID:web-auto,项目名称:wtf-core,代码行数:30,代码来源:XmlJuintReport.java

示例9: getDetailedStackTrace

import org.testng.internal.Utils; //导入依赖的package包/类
public static String getDetailedStackTrace(ITestResult tr) {
  String failureTrace = "";
  Throwable throwable = tr.getThrowable();
  if (throwable != null) {
    failureTrace = Utils.stackTrace(throwable, false)[0];
  } else {
    failureTrace = "No Stack Trace Found.";
  }
  return failureTrace;
}
 
开发者ID:web-auto,项目名称:wtf-core,代码行数:11,代码来源:BaseListener.java

示例10: generateReport

import org.testng.internal.Utils; //导入依赖的package包/类
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites,
		String outputDirectory) {
	if (Utils.isStringEmpty(config.getOutputDirectory())) {
		config.setOutputDirectory(outputDirectory);
	}

	// Calculate passed/failed/skipped
	int passed = 0;
	int failed = 0;
	int skipped = 0;
	for (ISuite s : suites) {
		for (ISuiteResult sr : s.getResults().values()) {
			ITestContext testContext = sr.getTestContext();
			passed += testContext.getPassedTests().size();
			failed += testContext.getFailedTests().size();
			skipped += testContext.getSkippedTests().size();
		}
	}

	rootBuffer = new XMLStringBuffer();
	Properties p = new Properties();
	p.put("passed", passed);
	p.put("failed", failed);
	p.put("skipped", skipped);
	p.put("total", passed + failed + skipped);
	rootBuffer.push(XMLReporterConfig.TAG_TESTNG_RESULTS, p);
	writeReporterOutput(rootBuffer);
	for (int i = 0; i < suites.size(); i++) {
		writeSuite(suites.get(i).getXmlSuite(), suites.get(i));
	}
	rootBuffer.pop();
	Utils.writeUtf8File(config.getOutputDirectory(), FILE_NAME, rootBuffer,
			null /* no prefix */);
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:36,代码来源:ATEXMLReporter.java

示例11: writeSuiteToFile

import org.testng.internal.Utils; //导入依赖的package包/类
private void writeSuiteToFile(File suiteFile, ISuite suite) {
	XMLStringBuffer xmlBuffer = new XMLStringBuffer();
	writeSuiteToBuffer(xmlBuffer, suite);
	File parentDir = suiteFile.getParentFile();
	if (parentDir.exists() || suiteFile.getParentFile().mkdirs()) {
		Utils.writeFile(parentDir.getAbsolutePath(), FILE_NAME,
				xmlBuffer.toXML());
	}
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:10,代码来源:ATEXMLReporter.java

示例12: writeSuiteResult

import org.testng.internal.Utils; //导入依赖的package包/类
/**
* Writes the specified ISuiteResult in the given XMLStringBuffer. Please consider that depending on the settings in
* the <code>config</code> property it might generate an additional XML file with the actual content and only
* reference the file with an <code>url</code> attribute in the passed XMLStringBuffer.
*
* @param xmlBuffer The XML buffer where to write or reference the suite result
* @param suiteResult The <code>ISuiteResult</code> to serialize
*/
  public void writeSuiteResult(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
    if (XMLReporterConfig.FF_LEVEL_SUITE_RESULT != config.getFileFragmentationLevel()) {
      writeAllToBuffer(xmlBuffer, suiteResult);
    } else {
      String parentDir =
              config.getOutputDirectory() + File.separatorChar + suiteResult.getTestContext().getSuite().getName();
      File file = referenceSuiteResult(xmlBuffer, parentDir, suiteResult);
      XMLStringBuffer suiteXmlBuffer = new XMLStringBuffer();
      writeAllToBuffer(suiteXmlBuffer, suiteResult);
      Utils.writeUtf8File(file.getAbsoluteFile().getParent(), file.getName(), suiteXmlBuffer.toXML());
    }
  }
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:21,代码来源:ATEXMLSuiteResultWriter.java

示例13: addTestResultException

import org.testng.internal.Utils; //导入依赖的package包/类
private void addTestResultException(XMLStringBuffer xmlBuffer, ITestResult testResult) {
  Throwable exception = testResult.getThrowable();
  if (exception != null) {
    Properties exceptionAttrs = new Properties();
    exceptionAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, exception.getClass().getName());
    xmlBuffer.push(XMLReporterConfig.TAG_EXCEPTION, exceptionAttrs);

    if (!Utils.isStringEmpty(exception.getMessage())) {
      xmlBuffer.push(XMLReporterConfig.TAG_MESSAGE);
      xmlBuffer.addCDATA(exception.getMessage());
      xmlBuffer.pop();
    }

    String[] stackTraces = Utils.stackTrace(exception, false);
    if ((config.getStackTraceOutputMethod() & XMLReporterConfig.STACKTRACE_SHORT) == XMLReporterConfig
            .STACKTRACE_SHORT) {
      xmlBuffer.push(XMLReporterConfig.TAG_SHORT_STACKTRACE);
      xmlBuffer.addCDATA(stackTraces[0]);
      xmlBuffer.pop();
    }
    if ((config.getStackTraceOutputMethod() & XMLReporterConfig.STACKTRACE_FULL) == XMLReporterConfig
            .STACKTRACE_FULL) {
      xmlBuffer.push(XMLReporterConfig.TAG_FULL_STACKTRACE);
      xmlBuffer.addCDATA(stackTraces[1]);
      xmlBuffer.pop();
    }

    xmlBuffer.pop();
  }
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:31,代码来源:ATEXMLSuiteResultWriter.java

示例14: generateExceptionReport

import org.testng.internal.Utils; //导入依赖的package包/类
private void generateExceptionReport(Throwable exception,ITestNGMethod method,String title) {
    out.println("<p>" + (title != null && title.startsWith("Failed")?"java.lang.AssertionError : ":"") + Utils.escapeHtml(title) + "</p>");
    StackTraceElement[] s1= exception.getStackTrace();
    Throwable t2= exception.getCause();
    if(t2 == exception)
        t2= null;
    for(int i=0;i<s1.length;i++)
        out.println((i>0 ? "<br/>at " : "") + Utils.escapeHtml(s1[i].toString()));
    if(t2 != null)
        generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage());
}
 
开发者ID:Flipkart,项目名称:harness,代码行数:12,代码来源:TestReporter.java

示例15: generateForResult

import org.testng.internal.Utils; //导入依赖的package包/类
private void generateForResult(ITestResult ans, ITestNGMethod method, int resultSetSize) {
	Object[] parameters = ans.getParameters();
	boolean hasParameters = parameters != null && parameters.length > 0;
	if (hasParameters) {
		tableStart("result", null);
		m_out.print("<tr class=\"param\">");
		for (int x = 1; x <= parameters.length; x++) {
			m_out.print("<th>Parameter #" + x + "</th>");
		}
		m_out.println("</tr>");
		m_out.print("<tr class=\"param stripe\">");
		for (Object p : parameters) {
			m_out.println("<td>" + Utils.escapeHtml(p.toString()) + "</td>");
		}
		m_out.println("</tr>");
	}
	List<String> msgs = Reporter.getOutput(ans);
	boolean hasReporterOutput = msgs.size() > 0;
	Throwable exception = ans.getThrowable();
	boolean hasThrowable = exception != null;
	if (hasReporterOutput || hasThrowable) {
		if (hasParameters) {
			m_out.print("<tr><td");
			if (parameters.length > 1) {
				m_out.print(" colspan=\"" + parameters.length + "\"");
			}
			m_out.println(">");
		} else {
			m_out.println("<div>");
		}
		if (hasReporterOutput) {
			if (hasThrowable) {
				m_out.println("<h3>Test Messages</h3>");
			}
			for (String line : msgs) {
				m_out.println(line + "<br/>");
			}
		}
		if (hasThrowable) {
			boolean wantsMinimalOutput = ans.getStatus() == ITestResult.SUCCESS;
			if (hasReporterOutput) {
				m_out.println("<h3>" + (wantsMinimalOutput ? "Expected Exception" : "Failure") + "</h3>");
			}
			generateExceptionReport(exception, method);
		}
		if (hasParameters) {
			m_out.println("</td></tr>");
		} else {
			m_out.println("</div>");
		}
	}
	if (hasParameters) {
		m_out.println("</table>");
	}
}
 
开发者ID:quanqinle,项目名称:WebAndAppUITesting,代码行数:56,代码来源:PowerEmailableReporter.java


注:本文中的org.testng.internal.Utils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。