Prerequisite : Selenium WebDriver Framework creation steps from STEP 1 to STEP 14 should be Implemented as described In previous posts.
We have Implemented software test data skip function In STEP 14. Now let we go ahead one more step In selenium testing data driven framework creation. If you know, We have a "Pass/Fail/Skip" column In our excel datasheets. That column Is reserved to report the software test data execution results like "PASS", "FAIL" or "SKIP". If you look at our test cases, We have not Introduced webdriver In our software test suites but we will Implement It very soon.
Read more tutorials on selenium WebDriver @Tutorials Part 1 and @Tutorials Part 2.
How To Report Test Data Execution Result In Excels
Same as reporting suite execution status as described In STEP 12, We will use "WriteResultUtility" function of SuiteUtility class In our test cases to report test data execution results In excel sheets. We will set flag "Testskip" = "True" In our software test cases (In @Test method) If test data has to skip. Same way, we will set "Testfail" = "True" If actual and expected values not match. And then we will create new method using testng's @AfterMethod annotation In all software test cases to report the test data set execution results on end of every test data set execution. "Testskip" and "Testfail" flags will be used In @AfterMethod method to write the results In excel sheets.
Download Updated Test Cases and Excel Files
I have updated all 4 test cases files to report software test execution results In related data excel sheet. I have Implemented logic of Summation, Subtraction, Multiplication and Division of test data In software test cases to get actual result. Also updated few expected result data Intentionally wrong In test cases data sheets to report test data as "FAIL". Download bellow given zip folder to get all the files.Extract the folder and copy-paste folder's files In "WDDF" project In Eclipse to replace existing files as described bellow.
(Note : It should replace existing file when paste It on package. It should not Insert new file.)
- Paste SuiteOneCaseOne.java File on com.stta.SuiteOne Package.
- Paste SuiteOneCaseTwo.java File on com.stta.SuiteOne Package.
- Paste SuiteTwoCaseOne.java File on com.stta.SuiteTwo Package.
- Paste SuiteTwoCaseTwo.java File on com.stta.SuiteTwo Package.
- Paste SuiteOne.xls File on com.stta.ExcelFiles Package.
- Paste SuiteTwo.xls File on com.stta.ExcelFiles Package.
Run Test Suites To Report Test Data Result
Now we are all set to run our test suites to verify that our test data result reporting function Is working fine or not.Note : Close all excel files before running your test suite. Otherwise you will get an error during your test suite execution.
Now Run your test suites from testng.xml file. On completion of test execution, Open SuiteOne.xls and SuiteTwo.xls files from com.stta.ExcelFiles Package. You will see that all the data set line's "Pass/Fail/Skip" column Is updated with "PASS" or "FAIL" or "SKIP" as shown In bellow given Image.
- If result Is "PASS" : Means expected and actual values are match.
- If result Is "FAIL" : Means expected and actual values are not match.
- If result Is "SKIP" : Means "DataToRun" flag Is set to "n" so that test data set execution has been skipped.
If you see In above Image, 4 test data line's has been reported as "SKIP" because their "DataToRun" flag Is set to "n". 3 test data lines has been reported as "PASS" because their expected and actual result has been match during test execution. 1 data line has been reported as "FAIL" because Its expected and actual result do not match.
So we have successfully Implemented data set result reporting function In our selenium software automation framework which Is driven by external data sheet data.