Selenium Testing Framework : Implement Test Case Skip Function

STEP 13
PrerequisiteSTEP 1 to STEP 12 should be Implemented as described.

In previous two steps, We have learnt how to skip specific software automation test suite's execution from your test and then reported software test suite execution status In excel file. So this was our basic requirement of our selenium software automation framework which Is driven by data of external excel sheet.



Why Need Test Case Skip Function?
Now other requirement of this webdriver automation framework Is It should be able to skip specific test case from the execution If "CaseToRun" = "N" against test case In excel sheet. Example : You have a software test suite with 5 different test cases. From these 5 test cases you wants to run only 3 test cases and wants to skip remaining 2 test cases.

How To Skip Specific Test Case From Execution
We have ready made "checkToRunUtility" function In "SuiteUtility" class which Is using "retrieveToRunFlag" function of "Read_XLS" class to retrieve "CaseToRun" flag from "TestCasesList"  sheet of test case's excel files. So we will use this function In our all four software test cases of both test suites. We will check "CaseToRun" flag In @BeforeTest method of every test case class.

Skip Test Case From Execution
Step 1 : 
Now let us try to skip execution of "SuiteOneCaseOne" test case from "SuiteOne" and "SuiteTwoCaseTwo" test case from "SuiteTwo". For that you have to set "SuiteToRun" and "CaseToRun" flags of all the test suites and test cases In different excel sheets as shown In bellow given Image.

Step 2 : 
2nd step Is you have to modify existing test case's java files of our data driven selenium software testing framework project "WDDF". I have already modified those files and you can get those files by downloading bellow given zip folder.
Extract the downloaded folder and copy-paste all four software automation test cases files on existing files of "WDDF" project In Eclipse as described bellow to replace existing files.
(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.
Running Test
Note : Before running test suite, Please make sure that your all .xls files are closed. If any file Is open then you will get an error during test suite execution.

Now we are all set run and verify execution result of both test suites. Run your test suites using testng.xml file.

On completion of execution, Look at the console file. It will print data of only "SuiteOneCaseTwo" and "SuiteTwoCaseOne" test cases In console. "SuiteOneCaseOne" and "SuiteTwoCaseTwo" has been skipped from execution so data will be not printed In console.

Testng execution result will looks like bellow.


So we have achieved our 2nd goal of skipping specific test cases from execution. Now You can set "CaseToRun" flag against test case In excel files as per your requirement to skip or execute that software automation test case.

3 comments:

  1. Hi,
    Getting error while trying to download step13.zip as well :(
    Thanks/Sourav
    --------------

    ReplyDelete

  2. i am getting error after running your script and my excel file "TestSuiteList.xls" getting corrupt.
    Please run your code at this stage.

    ReplyDelete
  3. Hi, How to run same test case multiple times?

    ReplyDelete