DataDriven Framework For WebDriver Step 10 - Adding testng.xml To Run Multiple Test Cases

STEP 10
Prerequisite
1. All the previous steps starting from STEP 1 to STEP 9 should be Implemented properly.
2. TestNG software unit testing framework should be Installed properly In eclipse. VIEW TESTNG INSTALLATION GUIDE.

Now our all four test cases from both the suites are able to read data from related excel file as described In STEP 9 of data driven framework creation. But right now main Issue Is we need to run all four test cases
one by one to execute all of them. Now we need something by which we can executed all the test cases from one place. As I have described earlier, We have to use TestNG In our data driven framework. So we can use testng.xml file In our software automation testing framework which will allow us to execute all the test cases from one place.

You can READ MORE TUTORIALS ON TESTNG FRAMEWORK for your reference.

Adding .xml files for both suites
First of all, We will create separate .xml files for both the test suites of software web application and then we will call both the .xml files In testng.xml file. I have created .xml files for both the test suites and you can download them by clicking on bellow given download links.

  1. SuiteOne.xml
  2. SuiteTwo.xml
Right now we have only 2 test suites so we have created only .xml files. If you have more test suites for your software web application then you need to create more .xml files In same way.

Copy both downloaded files and paste them on data driven project "WDDF" In eclipse.

Adding testng.xml file
Now you have to create testng.xml file. I have already created It for you. Click on bellow given download link to download It.
  1. testng.xml
Right now we have only two test suites for software web application so listed only two test suites In this testng.xml file. If you have more test suites for software web application and created more .xml files for each suite then also you need to add them In testng.xml file.

Copy above downloaded file and paste It on data driven project "WDDF" In eclipse.
Now your data driven project "WDDF" will looks like bellow In eclipse.

Running all Test cases from one place (testng.xml)
Now you are ready to run all four test cases of software web application from one place. For running both the test suites of data driven framework In eclipse Right click on testng.xml file and select "Run As" -> "Test TestNG Suite". It will run all four test cases from both the test suites and results will be displayed as bellow In testng results tab of eclipse at the end of execution.



Now onward, we will run test suites from testng.xml file to run both test suites.

7 comments:

  1. Hello Sir,

    I followed all the above mentioned steps and when I execute testng.xml file, it shows only 2 test cases SuiteOneCaseOne and SuiteOneCaseTwo test cases and not the complete 4 test cases.

    Please advice as I am not able to see SuiteTwo test cases.

    ReplyDelete
  2. Hi,
    when i run the testng suite it is not showing anything even error message also not showing in console. please help to overcome interestingly i am doing data driven framework.

    ReplyDelete
  3. Hi Ritesh what sollution u found for above question..

    ReplyDelete
  4. After running 1st file I got following output

    [TestNGContentHandler] [WARN] It is strongly recommended to add "" at the top of your file, otherwise TestNG may fail or not work as expected.
    [TestNG] Running:
    E:\backup\Training\WDDF\SuiteOne.xml

    FilePath Is : com.stta.utility.Read_XLS@20c09c92
    TestCaseName Is : SuiteOneCaseOne
    FilePath Is : com.stta.utility.Read_XLS@68ef77e9
    TestCaseName Is : SuiteOneCaseTwo

    ===============================================
    SuiteOne
    Total tests run: 2, Failures: 0, Skips: 2
    ===============================================

    ReplyDelete
  5. After running 2nd file I got following output

    [TestNGContentHandler] [WARN] It is strongly recommended to add "" at the top of your file, otherwise TestNG may fail or not work as expected.
    [TestNG] Running:
    E:\backup\Training\WDDF\SuiteTwo.xml

    FilePath Is : com.stta.utility.Read_XLS@1ec26dd5
    TestCaseName Is : SuiteTwoCaseOne
    FilePath Is : com.stta.utility.Read_XLS@cce2624
    TestCaseName Is : SuiteTwoCaseTwo

    ===============================================
    SuiteTwo
    Total tests run: 2, Failures: 0, Skips: 2
    ===============================================

    ReplyDelete