Skip to content

Instantly share code, notes, and snippets.

@einaralex
Created July 19, 2017 14:38
Show Gist options
  • Save einaralex/afaad58bc370d1e34cc441c142a289e5 to your computer and use it in GitHub Desktop.
Save einaralex/afaad58bc370d1e34cc441c142a289e5 to your computer and use it in GitHub Desktop.
Set headers script for SoapUI
import com.eviware.soapui.support.types.StringToStringMap
import com.eviware.soapui.impl.wsdl.teststeps.*
// loop through every teststep in that testcase
for(testStep in testRunner.testCase.getTestStepList()){
if(testStep instanceof WsdlTestRequestStep) {
def headers = new StringToStringMap()
headers.put("X-End-User","User")
headers.put("X-Audit-Guid","\${=java.util.UUID.randomUUID().toString().replace(\"-\",\"\").toUpperCase()}")
headers.put("X-System-Id","ID")
// Debugging messages
log.info("Setting HTTP headers ${headers} in test case ${testStep.getName()}")
// Set the headers
testStep.getTestRequest().setRequestHeaders(headers)
// Additionally add "Not SOAP Fault assertion
def assert_1 = testStep.addAssertion("Not SOAP Fault")
assert_1.setName("Not SOAP Fault")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment