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(){
                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++){

                    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();

softAssert.assertTrue(CommonAssertion.verifySelectEquipmentDivision1(), "selected eqip div not found");
    //    softAssert.assertAll();

  • The second block of code is not valid Java code. Could you replace this with the whole test class? Jun 18, 2019 at 9:55
  • What is the error you're seeing? Are the subsequent tests being marked as ignored/skipped?
    – anonygoose
    Jun 18, 2019 at 12:45
  • From the docs "When an assertion fails, don't throw an exception but record the failure. Calling assertAll() will cause an exception to be thrown if at least one assertion failed." So as I read your question, the behavior you see is expected. Your question isn't worded very clearly to me though, so I may have misunderstood. Jun 18, 2019 at 15:18
  • I think part of the issue is it skips all his other tests, which kind of sounds like there's a failing Before, and it's set to skip on config failure, which is default. Like you said though, it's unclear from the question.
    – anonygoose
    Jun 19, 2019 at 16:45

3 Answers 3


Try Assert.assertFalse(message, condition) Using this the framework will not stop. Assert false will happen only when the required condition matches.


int assetValue = 0;
boolean isElementPresent;


isElementPresent = driver.findElement("Locator of the element").isDisplayed();


catch (Exception e) 
isElementPresent = false;


assetValue ++;
//Do the required operation



Assert.assertFalse("Since the element is not present hence marking the test case as FAIL !!!", assetValue==0) 


With my experience in the software testing company I reviewed your provided code & comments and observed that there are two issues with the details:

1. The try block does not have any true return statement.
2. ---------------------------Soft Assert – Soft Assert collects errors during @Test. Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.

If there is any exception and you want to throw it then you need to use assertAll() method as a last statement in the @Test and test suite again continue with next @Test as it is.---------------------------------

As mentioned, commenting the softAssert got your program to run successfully i.e because it is supposed to be used at last.

Correct these, and the program might work. Post reply if it doesn't

  • that is what I have mentioned that if we are using assertAll then test cases should faile and continue for execution but in my case test case gets fails and stos execution if I write assertAll for any @test, and if I simply add softassert without using assertall then it works fine thats incorrect.
    – jay
    Jun 21, 2019 at 11:37

You can use "softAssert" as a parameter of Test annotation, like @Test(softAssert=true)

  • 2
    Please edit your answer to explain how using a soft assert annotation would solve the OP's problem.
    – Kate Paulk
    Jul 23, 2019 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.