Forum Discussion

CharlesHarold's avatar
CharlesHarold
Occasional Contributor
7 years ago
Solved

Get Current Test Step Name in Script Assertion returns Source Test Step Name?

I have a Script Assertion in an Assertion TestStep (name "Verify Response") that evaluates the response from a REST Request TestStep, so the "Source" for the Script Assertion is "REST Request" (the name of my REST Request TestStep).

 

I need to get the name of the current Assertion TestStep (e.g., "Verify Response"), but when I use the typical get current test step name methods, I actually get the REST Request TestStep's name, e.g.,

 

log.info "${context.getCurrentStep().getLabel()}"

// returns "REST Request"

log.info "${context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()}"
// returns "REST Request"

log.info "${context.currentStep.name}"

// returns "REST Request"

 

How do I get my Assertion TestStep's name ("Verify Response")?

 

p.s. My Assertion TestStep's actual name (not "Verify Response") contains information I'd like to use in my script

 

  • PaulMS's avatar
    PaulMS
    7 years ago

    Oh I see what you mean. The run button in the script assertion uses a "Virt testContext" according to the tool tip.

     

    However when you run the whole test case you should see the correct assertion test step name in the script log.

    Click Logs, Script log at the bottom of the window.

7 Replies