Forum Discussion

MalikVertika's avatar
MalikVertika
Senior Member
8 years ago

Trying to update resource value in SoapUI5.3 & it is not updated in TestSuite & testrequests. WHy?

Hey,

 

I'm trying to update a header resource value in Soap UI and that is not updated in the TestSuites --> TestRequests. Attached is the snippet. Can you please help me with this.

 

ResourceTestRequest

  • yanice's avatar
    yanice
    Senior Member

    Hello,

     

    It seems that the header configuration on the resources is not uploaded automatically in the Test Steps.  I ended up writing a groovy script like it is recommended here.

     

    For your case it will be something like that:

     

    import com.eviware.soapui.support.types.StringToStringMap 
    def headers = new StringToStringMap()
    headers.put("tui-app-name",'${#Project#tui-app-name}');
    testRunner.testCase.testSteps.each
    {
     q->
     if(q.getValue().config.type.equals("restrequest") || q.getValue().config.type.equals("request"))
     {
      q.getValue().getHttpRequest().setRequestHeaders(headers)
     }
    }

    if you run this groovy script at the beginning all the steps from your current TestCase will be updated with the corresponding value, if you want to add multiple headers you can proceed like the following:

     

    import com.eviware.soapui.support.types.StringToStringMap 
    def headers = new StringToStringMap()
    headers.put("tui-app-name1",'${#Project#tui-app-name1}');
    headers.put("tui-app-name2",'${#Project#tui-app-name2}');
    testRunner.testCase.testSteps.each
    {
     q->
     if(q.getValue().config.type.equals("restrequest") || q.getValue().config.type.equals("request"))
     {
      q.getValue().getHttpRequest().setRequestHeaders(headers)
     }
    }

    Yanice