Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Validation 如果一个测试用例失败,则不跳过测试用例进行验证_Validation_Selenium_Testng_Assert - Fatal编程技术网

Validation 如果一个测试用例失败,则不跳过测试用例进行验证

Validation 如果一个测试用例失败,则不跳过测试用例进行验证,validation,selenium,testng,assert,Validation,Selenium,Testng,Assert,我有以下测试用例: 登录-注销 登录-搜索-注销 登录-搜索-单击结果-注销 所有这3个测试用例都被认为是独立的,并且在一个testNg类中 如何验证第一个测试用例(即如何检查登录是否成功) 我尝试过使用assert,但是当assert失败时,其余的测试用例(实际上独立于第一个)都将被跳过 我如何确保我验证了所有测试用例,并且无论它们是否通过测试,我都应该继续执行该testNG类中的所有测试用例?看起来您正在寻找。或者您可以使用自定义。这是我对JUnit的ErrorCollector实现:

我有以下测试用例:

  • 登录-注销
  • 登录-搜索-注销
  • 登录-搜索-单击结果-注销
  • 所有这3个测试用例都被认为是独立的,并且在一个testNg类中

    如何验证第一个测试用例(即如何检查登录是否成功)

    我尝试过使用
    assert
    ,但是当
    assert
    失败时,其余的测试用例(实际上独立于第一个)都将被跳过


    我如何确保我验证了所有测试用例,并且无论它们是否通过测试,我都应该继续执行该testNG类中的所有测试用例?

    看起来您正在寻找。或者您可以使用自定义。这是我对JUnit的ErrorCollector实现:

        @Rule //collects errors without aborting test
        public ErrorCollector collector = new ErrorCollector();
    
        @Test
        public void SampleTest() throws Exception {
    
    ...
            try {
    
                // Verify label
                Assert.assertEquals("label"
                        ,driver.findElement(By.xpath("some_xpath")).getText());
    
            } catch (AssertionError e) {
                System.out.println("Report Error: " + e);
                collector.addError(e);
            }
    
    ...
    
    }
    

    请从这里的控制台复制您的代码和错误。谢谢。@Test(priority=0)public void Authentication()抛出中断异常{authPage=new authPage(driver);authPage.login(“KYCASH03”,”PPCQ@123“”;String actual=driver.getTitle();String expected=“General Search”;Assert.assertTrue(helpdesk.isDisplayed());authPage.logout();对格式、结构和拼写进行了改进。您认为其余的测试用例都将被跳过是什么意思?您是指2.和3.测试用例还是注销?因为根据您的代码,在断言失败后注销不会运行,但注销()会运行操作不是一个测试用例。剩余的测试用例我指的是Login-search\u logout和Login-search点击结果注销场景,我在Testng类中定义了另外两个方法,因为这三个测试用例彼此独立,我希望所有三个都能运行,而不管第一个失败。