cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Occasional Contributor

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super Contributor

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

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.

View solution in original post

7 REPLIES 7
Highlighted
Super Contributor

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

An assertion is not a test step in itself but if you need to find the assertion name check

https://community.smartbear.com/t5/SoapUI-Pro/print-assertion-name-status-and-message-via-groovy/td-...

Highlighted
Occasional Contributor

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

Interesting, but doesn't help me. I am beginning to think that what I need isn't possible; everything I've tried indicates that for my assertion, all it knows is the REST Request test step.

Highlighted
Contributor

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

My test step is "Login" and when I use the code above, they do return back correctly of my test step name.  Thanks.  

Highlighted
Super Contributor

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

CharlesHarold

Can you attach an image to show the assertion name that you want to use

Highlighted
Occasional Contributor

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

Step name I need is circled in orangeStep name I need is circled in orange

Yes, I've found 12 different ways to get the wrong Test Step name.

Highlighted
Super Contributor

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

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.

View solution in original post

Highlighted
Occasional Contributor

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

You are correct! I would have never figured that out, thank you!

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors