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


Java ITestResult.getThrowable方法代码示例

本文整理汇总了Java中org.testng.ITestResult.getThrowable方法的典型用法代码示例。如果您正苦于以下问题:Java ITestResult.getThrowable方法的具体用法?Java ITestResult.getThrowable怎么用?Java ITestResult.getThrowable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.ITestResult的用法示例。


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

示例1: run

import org.testng.ITestResult; //导入方法依赖的package包/类
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
    super.run(callBack, testResult);
    if (testResult.getThrowable() != null) {
        try {
            final Throwable testResultThrowable = testResult.getThrowable();
            String message = testResultThrowable.getMessage() != null ? testResultThrowable.getMessage() :
                    testResultThrowable.getCause().getMessage();

            if (message == null) {
                message = "Test failed";
            }

            new Screenshoter().takeScreenshot(message, TestUtils.getTestName(testResult));
        } catch (Exception e) {
            log("Couldn't take screenshot. Error: " + e.getMessage());
        }
    }
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:20,代码来源:AbstractSeleniumTest.java

示例2: onTestFailure

import org.testng.ITestResult; //导入方法依赖的package包/类
@Override
public void onTestFailure(final ITestResult result) {
    Current current = currentTestResult.get();

    if (current.isAfter()) {
        current = refreshContext();
    }

    //if testng has failed without any setup
    if (!current.isStarted()) {
        createTestResultForTestWithoutSetup(result);
    }

    current.after();
    final Throwable throwable = result.getThrowable();
    final Status status = getStatus(throwable);
    final StatusDetails details = getStatusDetails(throwable).orElse(null);
    getLifecycle().updateTestCase(current.getUuid(), setStatus(status, details));
    getLifecycle().stopTestCase(current.getUuid());
    getLifecycle().writeTestCase(current.getUuid());
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:22,代码来源:AllureTestNg.java

示例3: configurationError

import org.testng.ITestResult; //导入方法依赖的package包/类
private boolean configurationError( ITestContext context ) {

        // check if this is a configuration issue
        List<ITestResult> failedConfigurations = Arrays.asList(context.getFailedConfigurations()
                                                                      .getAllResults()
                                                                      .toArray(new ITestResult[context.getFailedConfigurations()
                                                                                                      .getAllResults()
                                                                                                      .size()]));
        for (ITestResult failedResult : failedConfigurations) {
            if (failedResult.getThrowable() != null) {
                logger.fatal("Configuration failed!", failedResult.getThrowable());
                return true;
            }
        }

        return false;
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:AtsTestngListener.java

示例4: setFailedTcAttribute

import org.testng.ITestResult; //导入方法依赖的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

示例5: onTestFailure

import org.testng.ITestResult; //导入方法依赖的package包/类
@Override
public void onTestFailure( ITestResult testResult ) {

    try {
        //Check if the test was successfully started, if not - make it started and then end it with failure
        String testName = testResult.getMethod().toString();
        if (!testName.equals(lastTestName)) {
            onTestStart(testResult);
        }

        sendTestEndEventToAgents();

        // if this is an assertion error, we need to log it
        Throwable failureException = testResult.getThrowable();
        if (failureException instanceof AssertionError) {
            if (failureException.getMessage() != null) {
                logger.error(failureException.getMessage());
            } else {
                logger.error("Received java.lang.AssertionError with null message");
            }
        } else {
            logger.error(MSG__TEST_FAILED, testResult.getThrowable());
        }

        // end test case
        logger.endTestcase(TestCaseResult.FAILED);
    } catch (Exception e) {
        logger.fatal("UNEXPECTED EXCEPTION IN [email protected]", e);
    }
    super.onTestFailure(testResult);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:32,代码来源:AtsTestngTestListener.java

示例6: configurationError

import org.testng.ITestResult; //导入方法依赖的package包/类
private boolean configurationError() {

        // check if this is a configuration issue
        List<ITestResult> failedConfigurations = getConfigurationFailures();
        for (ITestResult failedResult : failedConfigurations) {
            if (failedResult.getThrowable() != null) {
                logger.fatal("Configuration failed!", failedResult.getThrowable());
                return true;
            }
        }

        return false;
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:14,代码来源:AtsTestngTestListener.java

示例7: endTestcaseWithFailureStatus

import org.testng.ITestResult; //导入方法依赖的package包/类
private void endTestcaseWithFailureStatus( ITestResult testResult ) {

        try {
            //Check if the test was successfully started, if not - make it started and then end it with failure
            String testName = testResult.getMethod().toString();
            if (!testName.equals(currentTestcaseName)) {
                startTestcase(testResult);
            }

            sendTestEndEventToAgents();

            // if this is an assertion error, we need to log it
            Throwable failureException = testResult.getThrowable();
            if (failureException instanceof AssertionError) {
                if (failureException.getMessage() != null) {
                    logger.error(ExceptionUtils.getExceptionMsg(failureException));
                } else {
                    logger.error("Received java.lang.AssertionError with null message");
                }
            } else {
                logger.error(MSG__TEST_FAILED, testResult.getThrowable());
            }

            currentTestcaseName = null;
            lastTestcaseResult = TestCaseResult.FAILED.toInt();
            // end test case
            logger.endTestcase(TestCaseResult.FAILED);
        } catch (Exception e) {
            logger.fatal("UNEXPECTED EXCEPTION IN [email protected]", e);
        }

    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:33,代码来源:AtsTestngListener.java

示例8: setLog

import org.testng.ITestResult; //导入方法依赖的package包/类
private void setLog(ITestResult tr) {
	StringWriter exception = new StringWriter();
	if (tr.getThrowable() != null) {
		tr.getThrowable().printStackTrace(new PrintWriter(exception));
	}
	tr.setAttribute("log", MTLogBuffer.getStringLog() + exception);
}
 
开发者ID:21ca,项目名称:selenium-testng-template,代码行数:8,代码来源:HtmlReporter.java

示例9: generateForResult

import org.testng.ITestResult; //导入方法依赖的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

示例10: afterInvocation

import org.testng.ITestResult; //导入方法依赖的package包/类
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
    if(shouldBeInvoked(testResult.getInstance().getClass(), FastFailListener.class) &&
       testResult.getThrowable() != null && !failedClasses.containsKey(testResult.getInstance()))
            failedClasses.put(testResult.getInstance(), method);
}
 
开发者ID:yaroslav-orel,项目名称:ExtendNG,代码行数:7,代码来源:FastFailListener.java


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