Forum Discussion

AndreW273SK's avatar
New Contributor
8 years ago

JavaScript incrementing letter string properties

Hello all.


I am new to JavaScript, so I could use some help.

I need script for SoapUI that will increment letter string global properties for me each time I ran Test Case. It should looks like this: TC run: "aaaa"

2.nd TC run: "aaab"

and so on.


Script I have now, increments only number strings:



import java.text.SimpleDateFormat

incrementStringProperty(5, 'firstName') 

// defines incrementation of string property
void incrementStringProperty (end, propertyName) {
def propertyToChange = testRunner.testCase.testSuite.getPropertyValue(propertyName)
def propertyEnd = String.valueOf(Long.parseLong(propertyToChange.substring(propertyToChange.length() - end)) + 1)
def propertyStart = propertyToChange.substring(0, propertyToChange.length() - end)
for (int i = propertyEnd.length(); i < end; i++) {
propertyEnd = "0" + propertyEnd
testRunner.testCase.testSuite.setPropertyValue(propertyName, propertyStart + propertyEnd)

Can somebody help me with this please?


Thank you.

No RepliesBe the first to reply