Forum Discussion
Hi SmartBear217
One of the decent groovy scripters on here will be able to explain better than I - I only play with it - but what you've found is correct - for a Groovy TestStep - testRunner is available, but for a script assertion it isn't, so you have to use messageExchange
For example - the following works in a groovy script - the next is part of a script to grab a response header called 'originalFileName' that was generated from a step entitled 'POST Request (create call)'
//Takes one of the elements of the response Header
def value = testRunner.testCase.testSteps["POST Request (create call)"].testRequest.response.responseHeaders["originalFilename"]
Whereas for a script assertion to do the same thing I had to use messageExchange
//Takes one of the elements of the response Header
def value = messageExchange.modelItem.testStep.testCase.testSteps["POST Request (create call)"].testRequest.response.responseHeaders["originalFilename"]
Does that help at all? As I say - I'm not a groovy scripter I just play around with it - one of the other chaps on here will be able to explain it all
cheers,
rich
Thanks for the reply but I'm not sure this helps because the question was "How do I fail the test case without the testRunner?"
Related Content
- 4 years ago