How to continue execution when Assertion is failed

前端 未结 5 1515
小鲜肉
小鲜肉 2020-11-28 12:42

I am using Selenium RC using Java with eclipse and TestNG framework. I have the following code snippet:

assertTrue(selenium.isTextPresent(\"Please enter Emai         


        
5条回答
  •  离开以前
    2020-11-28 13:38

    I suggest you to use soft assertions, which are provided in TestNg natively

    package automation.tests;
    
    import org.testng.asserts.Assertion;
    import org.testng.asserts.SoftAssert;
    
    public class MyTest {
      private Assertion hardAssert = new Assertion();
      private SoftAssert softAssert = new SoftAssert();
    }
    
    @Test
    public void testForSoftAssertionFailure() {
      softAssert.assertTrue(false);
      softAssert.assertEquals(1, 2);
      softAssert.assertAll();
    }
    

    Source: http://rameshbaskar.wordpress.com/2013/09/11/soft-assertions-using-testng/

提交回复
热议问题