多重声明验证处理 [英] Multiple Assert verification Handling

查看:103
本文介绍了多重声明验证处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的测试方法中,该方法具有多个断言.我希望它能够运行,以便如果所有断言都通过,那么它将在我的测试管理工具(我们将Test Link与Selenium集成在一起)中将状态记录为"通过"

In my test method below, this method has multiple asserts. I want it to run so that if all the asserts pass then it will log the status as "Passed" in my test management tool (we are integrating Test Link with Selenium)

但是,如果任何一个断言失败,则testNG会产生一个断言错误;在这种情况下,我无法在TMT中将状态更新为"失败",因为该方法的执行已停止,并且运行已继续执行下一个方法.

But if any one assert fails than testNG generates an Assertion Error; in this situation I'm not able to update the status to "Failed" in my TMT, because this method's execution was stopped and the run has proceeded with the next method.

请提供一些帮助来解决此问题.

Please provide some help to solve this.

Test(dataProvider = "User_login")
public void StatusForm_Verification(String uname, String pwd)
        throws InterruptedException {
    NavigateToLogin();
    Dashboard RD = LoginAs_user(uname, pwd);
    Thread.sleep(2000);

        if (Integer.parseInt(ReviewedStatuscount) >= 1) {

            Assert.assertEquals("true",
                    revui.Btn_SaveReview.getAttribute("disabled"));
            Assert.assertEquals("true",
                    revui.Btn_submitReview.getAttribute("disabled"));
            Assert.assertEquals("true",
                    revui.Btn_Needmoreinfo.getAttribute("disabled"));
            status = TestLinkAPIResults.PASSED;

        } else {
            throw new SkipException(
                    "Test Skipping - Reviewed count is Zero");
        }
    }

我的问题是:如果任何一个断言失败,那么如何在Testlink应用程序中将状态更新为失败(即status = TestLinkAPIResults.FAILED)?

My question is : if any one assert fails, than how can I update the status to Failed in the Testlink application (i.e status = TestLinkAPIResults.FAILED)?

推荐答案

您可以使用@after并在测试执行后检查状态

You could use @after and check status after test execution

@After
public void statusCheck() {
    if (status!=TestLinkAPIResults.PASSED) {
        status = TestLinkAPIResults.FAILED;
    }
}

这篇关于多重声明验证处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆