Thursday 5 June 2014

TestNG Soft Assertions

Instead of writing a custom logic, the TestNG library itself offers the facility to perform Soft Assertions in your test.

To use testng soft assertion, you have to use testng SoftAssert class. This class will helps to not throw an exception on assertion failure and recording failure. If you will use soft assertion then your test execution will remain continue even If any assertion fails. Another most Important thing Is your assertion failure will be reported In report so that you can view It at end of test. You can use soft assertion when you are using multiple assertions In same test method and you wants to execute all of them even If any one In between fails.


SoftAssert s_assert = new SoftAssert();

  
@Test
   //In this method, Test execution will not abort even If any assertion fail. Full Test will be executed.
   public void soft_assert_text() {
   Actualtext = driver.findElement(By.xpath("//h2/span")).getText();
   //Text on expected side Is written Incorrect intentionally to get fail this assertion.
   s_assert.assertEquals(Actualtext, "Tuesday, 01 January 2014", "1st assert failed.");
   System.out.println("Soft Assertion -> 1st pagetext assertion executed."); 

20 comments:

  1. Software testing is an investigation conducted to determine the quality and performance of a product under test. This validation provides clear and independent review about the software. Software testing professionals have huge demand in leading software development industries.

    testing training in chennai

    ReplyDelete
  2. Thanks for sharing informative article on TestNG Soft Assertions. Your code is working great and recommended for software testing professionals.
    QTP Course In Chennai

    ReplyDelete
  3. Thanks for your informative post; selenium is portable automation testing tool to validate the performance and behavior of a software application or environment.
    Best Selenium training institute in Chennai

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Thank you for sharing TestNG soft Assertions. We also have another simple way for Soft Assertion which will not fail the test

    @Test
    public void testForSoftAssertWithNoFailure() {
    softAssert.assertTrue(false);
    }

    Test Automation

    ReplyDelete
  6. Myself mathews, working as a software tester in leading software development firm. Having a blog is very useful for me to share my experience and get assistance from co-software testing professionals. You can explore my blog @ software testing training in chennai.

    ReplyDelete
  7. Excellent article!!! LoadRunner is popular automation testing tool used for validating a software application/system under load. It delivers most precise information about the performance, functionality and behavior of the software product. Loadrunner Course in Chennai

    ReplyDelete
  8. I learned a lot at thedevmasters.com. It is an amazing service special there mentoring program gave me real hand on experience in troubleshooting. I was able to create a full selenium testing Project in less than 4 hour time all by myself. Amazing professional team of mentors and software educators.
    DevMaster also got me selenium testing . They gave very good exam preparation material
    Visit www.thedevmasters.com and robin@thedevmasters.com, 1(866)340-1375

    ReplyDelete
  9. Thanks for sharing such a informative blog with us..

    Software Testing Course at Learn Software Testing. We prepares individuals with current digital skills for the competitive global workforce.

    ReplyDelete
  10. Your information about Selenium scripts is really interesting. Also I want to know the latest new techniques which are implemented in selenium. Can you please update it in your website? Selenium testing training in Chennai

    ReplyDelete
  11. Hi, this is Yasmin from Chennai. I have read your blog. It’s very informative and useful blog. You have done really great job. Keep update your blog. Thanks..
    Regards.
    Selenium Training in Chennai | Selenium Training in Chennai

    ReplyDelete
  12. Assam 2564 Police Constable Recruitment 2016 Apply Online


    Good post. This is a very clear, informative and helpful post for all people...........

    ReplyDelete
  13. Mobile application testing is the application software that is developed to handle hand held mobile devices. The testing in mobile application can be done by automated or maual type.
    Mobile Application Testing Training in Chennai | mobile application testing | Appium Training in Chennai

    ReplyDelete

  14. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharng this information,this is useful to me...
    Android training in chennai
    Ios training in chennai

    ReplyDelete

  15. i am really happy to say it’s an interesting post to read . I learn new information from your article , you are doing a great job . Keep it up

    PSD to Wordpress
    wordpress website development

    ReplyDelete