Forum Discussion

Willa's avatar
Willa
Occasional Contributor
9 years ago

How to get Request names in the Mock Service Script

Hi all,

 

I want to dispatch responses based on request names (e.g. Request 1 -> Response 1, Request 2 -> Response 2, etc.). How can I get the name of the current request in the Mock Service?

 

I need something similar to

testRunner.runContext.currentStep.name

but for the request in the MockService

 

Thanks

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3

    One of the simplest way to get this done is to send the test step name as http header.

    For example, add a http header for the request step say 'STEP_NAME' and set the value as '${=context.currentStep.name}'

     

    And access this in the mock response dispath handler the way you needed.

     

    EDIT:

    If you aren't sure adding http headers, check here