Service Virtualization

 View Only
  • 1.  How to fetch specific row from excel sheet to test case

    Posted Oct 18, 2019 06:39 AM
    I am having multiple rows in excel sheet.
    Need to execute test case using specific data from excel sheet.
    When we use "read rows from excel file" option, it will execute all the rows or 1st row . It will not allow to select specific row.
    Please let me know if it is possible in DevTest.


  • 2.  RE: How to fetch specific row from excel sheet to test case
    Best Answer

    Posted Oct 18, 2019 10:11 AM
    Hi Gurukiran,

    When you define the excel sheet as a DataSource then indeed those are the 2 possible outcomes when you run the testcase once:
    • it executes the first row, (or it executes one (1) random row depending on how you defined the dataset)
    • or it executes all rows if you have a loop inside your testcase (or it executes all rows if you have no loop but then you have to define a global datasource and define a sufficient number of vUser instances in your staging document)

    Using the OOTB functionality you can realize your requirement as follows. In a step you will loop over all the rows until you encounter the row that you want to use for this test case:
    • Add an additional step (can be a Do Nothing step)
    • Define the excel sheet as a datasource to this step
    • Let the Do Nothing step loop onto itself
    • Add an assertion "Ensure Property Matches Expression", here you can test on whatever column in your excel to decide this is the row to use, if assertion is true then next step is next step in your test case flow. Also be aware that there is also a excel row number property available.
    • Define the data source with AtEnd --> Fail the test (Because this means the row you want to use is not in this excel sheet)
    Another option would be to create a script step and then use some java libraries to open the excel and select the row you want to use. But as an excel file isn't like a database and doesn't have an index what this java library does is basically somewhat similar to building the read loop into the devtest workflow itself.

    Hope this helps!

    ------------------------------
    Cheers,
    Danny
    ------------------------------



  • 3.  RE: How to fetch specific row from excel sheet to test case

    Posted Oct 22, 2019 07:09 AM
    Hi Gurukiran,

    I recommend using external/internal DBs with such scenarios. 

    Thanks.

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------