One to Many Data with XML Data Bank and Writable Data Source

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
How do we create a one to many data sour
Is there a way to setup an aggregate data source in a test suite that uses values from a single row of one data source (like a global) with multiple rows from another? For example, create a global data source that contains login information and use the same values for each row from another data source.

Thanks,

gozer
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hello,

    Currently you cannot use an Aggregate Data Source to get the desired "one-to-many" behavior. The Aggegate Data Source is designed to iterate all of its contained Data Sources at the same time. However, the XML Data Bank and Writable Data Source will allow you to do what you described. You can use the following procedure to get a regular Data Source to give you the "one-to-many" behavior.

    1) Add a Writable Data Source to your project. The Writable Data Source is what lets us iterate independent of the other Data Sources.

    2) If you have more than one "global" parameter in your Data Source, right-click on the single Writable Data Source column and select Insert to add additional columns. Rename the columns to something matching your original Data Source columns.

    3) Add a Method Tool as a Set-Up Test to your project. This method will act as an interface to your "global" Data Source.

    4) Let's assume the column names you want to access are named "username" and "password" from the Data Source "Credentials". Add the following code to your method:

    CODE
    from soaptest.api import *

    def getCredentials(input, context):
      username = context.getValue("Credentials", "username")
      password = context.getValue("Credentials", "password")
      return SOAPUtil.getXMLFromString( [ username, password ] )

    def addDataSources(context):
      return "Credentials"

    5) Now chain an XML Data Bank to the output of the Method Tool [Right-click the Method and select Add Output].

    6) Run the test once to populate the XML Data Bank, then select the XML Data Bank from the tree.

    7) Select the element z0, which corresponds to the "username" parameter, and click "Add".

    8) Click "Modify" and select "DataSource column name". Select "Writable Data Source Column" and select the corresponding name.

    9) Repeat steps 7 and 8 for z1.

    For clarity, I have attached a project file demonstrating the end result. The project was created with SOAtest 4.5.2. The SOAP Client in the example project has a Username Token header that uses the global values. The SOAP Client is also parameterized with values from a different data source.

    Once you have set this up, when you parameterize other SOAP Client tools, you are free to use both the values from the Writable Data Source and values from another Data Source. Note that in addtion to the "one-to-many" scenario you described, this procedure will also allow you to do combinatorial iteration. For example, in the same project the "Credentials" Data Source contains 2 rows, and the other Data Source contains 4 rows. If you run the project, the SOAP Client will be executed 8 times.

    Let me know if you have any issues with this solution or if it failed to fully address your question.
Sign In or Register to comment.