Dynamic request payload generation for different test cases
I have a requirement where I need to generate the payload dynamically before sending the request to a service. Here, I have total 30 test cases where the structure of the payload is different for each test cases.
Our main XML payload:
<?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book> </catalog>
I need to change the above XML depending on the testcase requirements as shown in the below example.
For example,
Testcase 1: Send the request without having <author>
tag.
Testcase 2: Send the request without having <title>
tag.
Testcase 3: Send the request without having <price>
tag.
Testcase 4: Send the request without having <publish_date>
tag.
Testcase 5: Send the request without having entire <book>
tag.
Testcase 6: Send the request without having id attribute of the <book>
tag.
and so on.
How to perform this kind of scripting in SOATEST? Or is there any existing tool available in SOATEST?
Best Answer
-
I would first create a test for each "operation". In other words, are all 30 of these test cases for the same URL and HTTP method or different ones? This just affects how many tests you are creating. If they are all for the same URL and HTTP method then you would just be creating one test. Each test would be a REST Client or Messaging Client that has the XML payload configured using either Form XML or Form Input where all the elements are initially present.
Next, you would parameterize your test(s). With data source parameterization, you can define the values for each element and also say which ones are conditionally excluded.
See:
Understanding How SOAtest Performs Functional Testing Using Data Sources
Populating and Parameterizing Elements with Data Source Values
Using Data Source Values to Configure if Optional Elements Are Sent
Using Data Sources with Form XML: Excluding Elements and Attributes1
Answers
-
Test case examples:
For example,
Testcase 1: Send the request without having<author>
tag.
Testcase 2: Send the request without having<title>
tag.
Testcase 3: Send the request without having<price>
tag.
Testcase 4: Send the request without having<publish_date>
tag.
Testcase 5: Send the request without having entire<book>
tag.
Testcase 6: Send the request without having id attribute of the<book>
tag.
and so on.0 -
Thank you @benken_parasoft
0