Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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
Testng 我在我的脚本中使用了软断言,但在失败的情况下,它不会继续脚本的其余部分,并移动到下一个测试用例_Testng_Assertion - Fatal编程技术网

Testng 我在我的脚本中使用了软断言,但在失败的情况下,它不会继续脚本的其余部分,并移动到下一个测试用例

Testng 我在我的脚本中使用了软断言,但在失败的情况下,它不会继续脚本的其余部分,并移动到下一个测试用例,testng,assertion,Testng,Assertion,这是我的密码: @Test(priority=1) public void verifyPageTitle () throws InterruptedException { String Actual_title=driver.getTitle(); String Expected_title = "Abc"; SoftAssert assertion = new SoftAssert(); //Soft Assertion System.out.println("verifyPageTit

这是我的密码:

@Test(priority=1)
public void verifyPageTitle () throws InterruptedException
{
String Actual_title=driver.getTitle();

String Expected_title = "Abc";

SoftAssert assertion = new SoftAssert(); //Soft Assertion
System.out.println("verifyPageTitle is started");

assertion.assertEquals(Actual_title, Expected_title, "URL doesn't n 
match");
assertion.assertAll();
System.out.println("verifyPageTitle is completed");
}
此处不打印“verifyPageTitle已完成”,但断言失败。

请参阅

Soft Assert–Soft Assert在@Test期间收集错误。当Assert失败时,Soft Assert不会引发异常,并将在Assert语句之后继续执行下一步

如果存在任何异常,并且您想抛出它,那么您需要使用
assertAll()
方法作为@Test和Test套件中的最后一条语句,然后继续执行下一个@Test

当断言失败时,不要抛出异常,而是记录失败。如果至少有一个[soft]断言失败,则调用
assertAll()
将引发异常

也就是说,
SoftAssert#assertAll
将在调用时将任何“软断言”转换为“抛出的异常”:如果存在“失败的软断言”,则调用
assertAll
将立即终止测试的执行,从而跳过当前测试方法中的任何剩余代码