Forum Discussion

JCatloth's avatar
JCatloth
New Contributor
14 years ago

[Resolved] test step script result in script assertion

I have a test step script like so:

def etag = testRunner.testCase.getTestStepByName("getLatest").testRequest.response.responseHeaders['ETag'].get(0)
etag.toInteger()+1

In a subsequent test step I'd like to assert that a response header matches the above result. testRunner isn't available in script assertions as far as I can tell. Is it possible to reference the output of a test step from within a script assertion? Or is there another approach?

Note: This is a cross post the community board the other day. I just purchased a pro license and thought I would try here since there were no replies on the other board.

2 Replies

  • RJanecek's avatar
    RJanecek
    Regular Contributor
    Hi,

    maybe this example helps you. I am testing here response header:

    def header = context.currentStep.getHttpRequest().getResponse().properties["responseHeaders"]
    assert header["#status#"].toString().contains("405 Method Not Allowed")
  • JCatloth's avatar
    JCatloth
    New Contributor
    Thanks, that got me in the right direction. What I was looking for was

    context.expand('${myTestStepScript#result}')