Delivered by FeedBurner

Selenium WebDriver Framework : Reporting Test Failure In TestNG Report

In selenium webdriver automated data driven framework creation process, We have Implemented total 15 steps till now and we have successfully achieved our goal of reporting software application's test data results In excel sheets In step 15. We are going very slowly to create data driven framework for your better understanding.

Prerequisite : Selenium webdriver software testing tool's data driven framework creation STEP 1 to STEP 15 should be Implemented as listed on THIS PAGE.

In this step, We will Implement functionality to report failure of software test data, test case and test suite In testng reports.

How To Report Failure In TestNG Report?
We can use assertions of testng to report failure In testng Reports. Testng has two assertion methods. 1st Is hard assertion and 2nd Is soft assertion method. You will find the links for both types of assertion methods with examples on THIS PAGE. We can use any of them In our selenium webdriver testing framework 

If you will use hard assertion to report results, Your test will be aborted on assertion failure. If you will use soft assertion, Your test execution will remain continue even If your test fails. You can use any one of them or both of them In your software test cases as per your requirement.We will use soft assertion In our data driven framework to report the results In testNG reports.

Updating Test Cases To Report Results In TestNG
We need to update all our four test cases to report results In testng reports. For that, First of all we will create object of testng SoftAssert class In our test cases and then we will use It as a assertion when ever required. At last of test case, We will use assertAll() method of SoftAssert class Inside If condition to report the result.

Download Updated Test Cases
I have updated all software test cases with soft assertion Implementation to report the results In testng report. Excel files should be same as STEP 15. Download bellow given folder to get updated software test cases files.

Extract the downloaded zip folder and copy-paste files as described bellow.
(Note : It should replace existing file when paste It on package. It should not Insert new file.)
  • Paste File on com.stta.SuiteOne Package.
  • Paste File on com.stta.SuiteOne Package.
  • Paste File on com.stta.SuiteTwo Package.
  • Paste File on com.stta.SuiteTwo Package.
Run Test Suites To Report Result In TestNG Reports
Now we are ready to run our data driven framework project's test suites to verify that test failure Is reported In TestNG reports or not.
Note : Close all excel files before running your test suite. Otherwise you will get an error during your test suite execution.

Run your test suites from testng.xml file. On completion of execution, View testng report. It will looks as shown In bellow given Image.

As you can see In above Image, SuiteOne, SuiteOneCaseOne and test data line Is reported as fail because expected and actual results are not matching. This way you can report failure In your testng reports using soft assertions.

No comments:

Post a Comment