I have used soft assertion in my test cases, but it stops the execution of all the next test cases. what I know if we are adding soft assertion then particular test case should fail and it should jump to the next test case successfully. Below is
my code:
public static boolean verifySelectEquipmentDivision1(){
try{
int count=0;
String[] eqipDiv={“A”,”A&B”,”CE”};
WebElement eqipDivdDropdown=Driver.getDriver().findElement(By.xpath(PageUtility.SELECT_EQUIPMENT_DIVISION));
Select selectTimePeriod=new Select(eqipDivdDropdown);
List<WebElement> eqipDivOptions=selectTimePeriod.getOptions();
for(WebElement we:eqipDivOptions){
for(int i=0;i<eqipDiv.length;i++){
if(we.getText().equalsIgnoreCase(eqipDiv[i])){
count++;
}
}
}
if(count==eqipDiv.length){
System.out.println(“matched”);
}
else{
System.out.println(“not matched”);
}
}
catch(Exception e){
System.out.println(“not selected”);
}
return false;
}
If am not adding assertAll(); it successfully execute my test cases, but to show this test case fail, I have added asserall() method and it stop execution of next test cases;
public void verifyEqiDiv()
SoftAssert ssoftassert=new SoftAssert();
@Test
softAssert.assertTrue(CommonAssertion.verifySelectEquipmentDivision1(), “selected eqip div not found”);
// softAssert.assertAll();
createNewReport.selectEquipmentDivision();
}
Source: Read More