Forum Discussion

ab_soapui's avatar
ab_soapui
Occasional Contributor
15 years ago

How to add different request templates in Soap UI for different testcases.

Hi.

I have multiple test request templates; I have to upload one of them depending on the test case, which i am reading from a csv file.

For example for some testcase i want to upload following test request template.
-----------------------------------------------------------------------------------------------------

 

 
     
     
        2
        4
     

     

 
 


For some other testcase i want to upload following test request. (basically its array of requests)
-------------------------------------------------------------------------------------------------------------------------

 

 
     
     
        2
        4
     

     
        20
        40
     

     

 
 


Same request template example with three nodes in the requests.
------------------------------------------------------------------------------------------


 

 
     
     
        2
        4
     

     
        20
        40
     

     
        200
        400
     

     

 
 



I am passing the testdata accrodingly from csv file.

How can i upload some request template using groovy script, so that for running a separate testcase, i can upload the respective request template?
Is there any other way to solve this kind of problems?

Any kind of help is greatly appriciated.

3 Replies

  • You could always have each of the three different requests as separate steps in your Test Cases and then use a Groovy Script to go to the appropriate one of the three requests based on a parameter

    testRunner.gotoStep(testRunner.testCase.getTestStepIndexByName('YourTestStep')
  • ab_soapui's avatar
    ab_soapui
    Occasional Contributor
    Thanks a lot for reply.... As i am new to SOAP UI, this one really helps me...


    But in this case i need to load the different xml requests template manually, before running the test suite .
    This the way how i am doing right now.

    Is there any way we can load these request xml templates using groovy script.


    Thanks in advance...
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi anusooya.

    In your scenario try the below following , First you need to have a Initialize Request step with the dummy XML.

    Name the below XML as "Initialize"


     

     
         
         
            ?
            ?
         

         
            ?
            ?
         

         
            ?
            ?
         

         

     
     


    // get request property
    request1 =    groovyUtils.getXmlHolder("Initialize#Request")
    def actualXML= request1.xml

    // set request property
    request5 = testRunner.testCase.getTestStepByName( "AddCalcList" )
    request5.getProperty("request").setValue(actualXML)


    Now you can map your input values from your CSV file, but still your request XML looks incomplete because your XML may have few empty tags after the Input values are mapped.
    For that you need to write groovy script to remove the empty tags from your actual Request XML.

    please let me know if you are not clear with my solution.

    Regards
    Anand.