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."); 

24 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
    Replies
    1. Thanks for sharing it Pavithra.

      Delete
  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. Thanks for sharing informative article on mobile testing. It helped me to understand the future of mobile application development and need of mobile application testing training. Think of joining mobile application testing training in Chennai from reputed IT placement or training academy.

    ReplyDelete
  12. Thanks for sharing this information. I read your blog and found it very useful. I used i in my training as it is easy to understand for beginners. It is important to make sure that the software application working precisely for the reason it originally designed for.
    best software testing training institute in Chennai | mobile application testing training in T Nagar | best software testing training institute in Chennai

    ReplyDelete
  13. 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
  14. Assam 2564 Police Constable Recruitment 2016 Apply Online


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

    ReplyDelete
  15. 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
  16. Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    salesforce training in chennai | salesforce training institute in chennai

    ReplyDelete

  17. 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

  18. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Android App Development Company

    ReplyDelete
  19. This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things...
    iOS App Development Company
    iOS App Development Company

    ReplyDelete
  20. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    <Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text
    Mobile Marketing Services
    mobile marketing companies
    Sms API

    ReplyDelete
  21. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete