Forum Discussion

cdunne's avatar
cdunne
Contributor
16 years ago

repeating elements when using xls datasource?

Hi,

Is it possible using a spreadsheet to test the cardinality of the repeating element? For example, one of our elements has a repeating child element:

...

             
             
                        ?
                          ?
             

             

...


I would like to generate the requests below


Scenario 1:
...

             

...


Scenario 2:
...

             
                        1
                          Prod1
             

             

...


Scenario 3:
...

             
                        1
                          Prod1
             

             
                        2
                          Prod2
             

             

...


Is this possible using a spreadsheet or should I be considering a file datasource with the different xml requests needed? 

We have to run about 1000 scenarios (and some of our messages will have hundreds of elements per message) so I'd rather  maintain a spreadsheet than 1000 xml files.

thanks for your advice

..Garret

4 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Garret,

    hmm.. is the number of CustomerOrderItem elements fixed or can it change for each request?

    - If it's fixed, you could create a groovy script that assigns the values
    - If it's dynamic, the groovy script would also have to create the xml for each item and then insert the whole block into the request

    regards,

    /Ole
    eviware.com
  • Hi Ole,

    In the live environment the number of elements will change per request. In testing it would be sufficient if we always test 2 elements.

    How would you suggest we arrange our spreadsheet & groovy script?

    Is it possible to have the main request fields in one worksheet, then reference another worksheet per repeatable element perhaps?
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    hmm.. if you want to add all rows in your datasource to one request you could do as follows:

    1) DataSource
    2) Groovy script that aggregates and builds xml
    3) DataSourceLoop back to (2) for each row in (1)
    4) Request that uses aggregated xml

    The key here obviously being the script in (2), something like

    // get existing..
    def xml = context.xml
    if( xml == null )
      xml = ""

    // aggregate row
    xml += "<CustomerOrderItem><Id>"
    xml += context.expand( "${DataSource#id}"  )
    xml += "</Id><Name>"
    xml += context.expand( "${DataSource#name}"  )
    xml += "</Name></CustomerOrderItem>"

    // save
    context.xml = xml


    In your request you could then have the following xml:

    <CustomerOrder>
                ${xml}
    </CustomerOrder>


    makes sense?

    regards!

    /Ole
    eviware.com