如何在TestNg和Allure报告框架中添加超时测试用例失败?

时间:2018-11-20 06:25:01

标签: selenium testng allure

如果我在TestNG.xml和方法中使用以下超时时间,则无法写入魅力测试结果。

<test name="TestName" time-out="60000">
        <classes>
            <class name="ClassName">
                <methods><include name="MethodName"></include>
                </methods>
            </class>
        </classes>
    </test>

OR

@Test (timeOut = 10*60000)

例外: io.qameta.allure.AllureResultsWriteException:无法写入魅力测试结果 造成原因:java.nio.channels.ClosedByInterruptException

我使用的监听器:

public class AllureListener implements IHookable {

    @Override
    public void run(IHookCallBack callBack, ITestResult testResult) {

        callBack.runTestMethod(testResult);
        if (testResult.getThrowable() != null || testResult.getStatus() == ITestResult.FAILURE
                || testResult.getStatus() == ITestResult.SKIP
                || testResult.getStatus() == ITestResult.SUCCESS_PERCENTAGE_FAILURE
                || testResult.getStatus() == ITestResult.SUCCESS_PERCENTAGE_FAILURE) {
            String methodName = testResult.getName().toString().trim();
            ITestContext context = testResult.getTestContext();
            WebDriver driver = (WebDriver) context.getAttribute("driver");
            if (driver != null) {
                AllureReportUtil ru = new AllureReportUtil();
                ru.addAttachment(driver, methodName);
            }
        }
}

请帮助我。

0 个答案:

没有答案