If there are two test cases and the first one failed, in that case I don't want to stop the execution. What needs to be added?

Without using TestNG annotations, try/catch, using selenium only.

  • 1
  • 1
    you can use java shutdown hook
    – PDHide
    May 9 at 15:17
  • 1
    What does Selenium have to do with test code? Selenium a browser manipulation library. May 10 at 6:49
  • @JoãoFarias it's a common tool used by MANY software test automation engineers. You'll note it's even part of several tags and many questions on this site.
    – Mark Mayo
    May 10 at 8:11
  • @MarkMayo Yes, but it doesn't have anything to do with test code flow. Selenium does browser manipulation, it's a library you call, not a framework that controls the code execution. May 10 at 8:16

The purpose of using any test automation tool is to fail when the assertion fails. However, how you write your tests also matter. It's recommended when writing tests to use the FIRST principle.

FIRST stands for:

  • Fast
  • Independent or Isolated
  • Repeatable
  • Self-validating
  • Thorough or Timely

In regards to the question: "I don't want to stop the test execution when one test fails." In this case, your tests need to be "Independent" and "Self-validating."

If one test fails, it only fails that test and the other tests are executed (Independent). A test should not be used as set up for another test or be a pre-condition for another test. The results of one test should not determine the success or failure of another test (Self-validating).

If you do need any data that is used for more than one test, you need to set that up separately so that it is reusable.

If you do need test setup or pre-conditions, then you need to use beforeAll() or beforeEach() methods from your test assertion library (TestNG in this case)


Use soft assertions. At the end of both test cases, you may do a softAssert.assertAll() which will also list out the failed test case for you.

    public void softAssert(){
        SoftAssert softAssertion= new SoftAssert();
        System.out.println("softAssert Method Was Started");
        System.out.println("softAssert Method Was Executed");

For more details refer this link - https://www.softwaretestingmaterial.com/soft-assert/

  • SoftAssert is coming with TestNG.Isnt it?
    – ChathuD
    May 11 at 3:36

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