Get test step name via property expansion in groovy step
Is it possible to get the test step name via a property expansion, or some other method that is automatically adjusted along with test step name changes?
When a property expansion is used in a groovy step, it is automatically updated when the test step name is changed.
For example, have the following property in a groovy step:
def id = context.expand( '${TestStep 1#id}' )
Change the name of the referred test step "TestStep 1" to "01 - test step" and this is automatically adjusted to:
def id = context.expand( '${01 - test step#id}' )
In our project we use some scripts to for example repeat a rest request step until the expected response is returned, or until a maximum number of attempts has been reached. In those scripts we refer to the test step to repeat by name:
def testStep = "TestStep 1"
Poll(testStep, responseProperty, expectedValue)
^ our "Poll"-method repeats "testStep" until the value of that test step's "responseProperty" is equal to the "expectedValue". Or a maximum number of 20 tries with a time out of 500 milliseconds between each attempt is reached.
But that "testStep"-variable is not automatically adjusted along with test step name changes.
We have some other methods that also rely on referring to a rest request test step by name from another groovy test step. As we use this a lot, changing test step names always comes with the risk of breaking tests.