Service Virtualization

Expand all | Collapse all

Delimited Data Set for dynamic file

  • 1.  Delimited Data Set for dynamic file

    Posted 02-11-2019 06:57 AM

    #Delimited Data Set 

     

    Dealing with Delimited File Data set in a sub process is creating trouble when the Delimited file will be generated dynamically in execution time . 

     

    Does anyone face the same issue ?

     

    Things I have already attempted but did not work -

     

    1. Put a default file name in the data set which will always be present there . Later change the name to desired file to avoid staging errors when test case loads to ITR .

    2. cleared the heap before executing ITR.

     

     #



  • 2.  Re: Delimited Data Set for dynamic file

    Posted 02-11-2019 03:37 PM

    What version of DevTest are you using?

    I wonder if there is a configuration issue with the Sub-process and/or the calling test case. 

    In the Sub-process, are the expected properties passed by the caller defined in the input parameters list? 

    They cannot be defined in Prospective Input Parameters. They must be input parameters.

    The default value in the below Sub-process enables it to run when the Sub-process is executed in ITR mode.

    In the main process that is calling the Subprocess, you should be able to pass a property in the value side of the key/value pair. For example,

    In the following example, the Main test case contains a Create Your Own Dataset having two (2) file names. As each row is read, the value of the row is placed in the Main test case's {{defaultFile}} property.  

    For each defaultFile, the subprocess is called.  

     

    The subprocess (below) opens the file past to it and iterates over each entry in the CSV file.

    After reading a row, the subprocess prints the content, loops for the next row, until all rows are processed.

      

    At end of the dataset, the sub-process returns control back to the Main process. 

     

    The main process reads the next file name and calls the subprocess to start processing against the next file found in the Create Your Dataset.

     

    For simplicity, Print Name and State step in the subprocess simply outputs the {{defaultFile}} property value and lists the values of two (2) columns in the CSV file (e.g., NAME and STATE). These are printed in the Workstation.log file using the _logger.info. Sample code is:

    _logger.info("File is: {} and data is: {}",
                 testExec.getStateValue("defaultFile"),
                 testExec.getStateValue("NAME") + " - " + testExec.getStateValue("STATE") );

     

    After running the main test and calling the subprocess, the log indicates that both datasets are accessed and display their respective content. The output below is abbreviated but does show the content of each file and column.

    2019-02-11 INFO com.itko.lisa.script.logger - file name is: Delimited_File_2
    :

    2019-02-11 INFO com.itko.lisa.script.logger - File is: Delimited_File_2 and data is: Mike - CO
    2019-02-11 INFO com.itko.lisa.script.logger - File is: Delimited_File_2 and data is: Raj - PA
    :

    2019-02-11 INFO com.itko.lisa.script.logger - file name is: Sample_Delimited_File
    :

    2019-02-11 INFO com.itko.lisa.script.logger - File is: Sample_Delimited_File and data is: Joel - TX
    2019-02-11 INFO com.itko.lisa.script.logger - File is: Sample_Delimited_File and data is: Sam - TX
    2019-02-11 INFO com.itko.lisa.script.logger - File is: Sample_Delimited_File and data is: Mark - FL

    :

     

    Changed the main.tst to use a property called {{fileToProcess}} and uploaded an example test case with subprocess along with excerpted Workstation.log file as shown above.

    Attachment(s)

    zip
    WIP_STUFF.zip   9K 1 version
    zip
    workstation.log.zip   775B 1 version