Forum Discussion

Raven25's avatar
New Contributor
2 years ago

Add test step name and project name to header SOAP test

Hi!   I'm pretty new to testing so still figuring everything out the best I can ğŸ˜€   I was wondering is someone could help me out with the following dilemma: To make my life a bit easier, I want...
  • KarelHusa's avatar
    2 years ago

    Hi Raven25,

    The approach you have chosen definitely makes sense.


    To modify the test step headers, you should use TestRunListener.beforeStep. Also, you will be able to use the testStep variable. You can look at the following script and accommodate it for your needs.



    if (testStep instanceof HttpRequestTestStep) {
    testRequest = testStep.testRequest

    // Create new headers map
    def headers = new StringToStringMap()
    // Copy existing headers
    testRequest.requestHeaders.each { headers.put(it.key, it.value[0])}
    // Add TestStep Name
    headers.putIfAbsent("x-Testing-TestStep", testStep.getName())



    Best regards,