Service Virtualization

  • 1.  How to read specific rows and also exclude specific rows from excel in Test case and write in output?

    Posted Feb 20, 2019 11:13 PM

    How to read specific rows and also exclude specific rows from excel in Test case?

    Suppose I have a set of 5 rows data in excel and I create a small test case as below

    a. I add a Do-nothing step and add a data set to "read rows from excel"

    b. I now want only 2nd row to be displayed in next step as "Output log message"

    Other requirement is I want all other rows to be displayed except 2nd row.

     

    can someone tell which assertion or filters can help get this doneand  how?



  • 2.  Re: How to read specific rows and also exclude specific rows from excel in Test case and write in output?

    Posted Feb 21, 2019 01:00 AM

    Hi Preeti,

     

    Please refer the post Custom Dataset-Read Specific rows from excel file (Start Row - End Row) . Hope it will help you. Also you can write a Java code using Execute script(JSR-223) step to achieve your requirement.

     

    Regards,

    Manik



  • 3.  Re: How to read specific rows and also exclude specific rows from excel in Test case and write in output?

    Posted Feb 21, 2019 04:06 AM

    Hey Manik,

     

    Thanks a lot for the help.

    I don't have any custom dataset option available.

     

    Is there any way to fetch a cell from excel and write in output??



  • 4.  Re: How to read specific rows and also exclude specific rows from excel in Test case and write in output?

    Posted Feb 21, 2019 05:18 AM

    Hi Preeti,

    If you use the below approach you don't need dataset.

    You will get lots of code snippets in google . Just type "read rows from excel file" in google and it will bring you lot of links having the similar code to fetch a cell from excel .

    Make sure you download the jar Apache POI and put that in your  LISA_HOME_PATH\lib\shared\   path.

    Restart the workstation and write the java code in Execute script(JSR-223) . In order to assign the value which you had read from excel and write in output step please use testExec.setStateValue("output",celldata).

    In the output step please write{{celldata}} to display the output log message.

     

    Regards,

    Manik



  • 5.  Re: How to read specific rows and also exclude specific rows from excel in Test case and write in output?
    Best Answer

    Broadcom Employee
    Posted Feb 21, 2019 05:18 AM

    Hi,

    When you are reading a DataSet then for each iteration there are properties created for each of the columns.

    BUT ADDITIONALLY there is also a row number property created. (Do test and keep in your dataset and you will see how the property is named).

    You can add an assertion to your Do Nothing step testing if this row number property has value 2 and then go to a next step to process. If you need the opposite case, not processing row 2 then your assertion can loop back to the Do Nothing step.

     

    Cheers,

    Danny



  • 6.  Re: How to read specific rows and also exclude specific rows from excel in Test case and write in output?

    Posted Feb 21, 2019 06:57 AM

    Hi Danny,

    Thanks this I have successfully achieved. 

     

    Pretty - PFA the screenshot FYR.

     

    Regards,

    ManikRead Specific Row from Dataset