Forum Discussion

SoapRookie's avatar
SoapRookie
Occasional Contributor
11 years ago

Appending time stamp to a request parameter name

I am working on REST apis.
I would like to create new users every time by calling a method, env.createUser. This method requires a parameter, userName.
I would like this userName to have values in the format, user_yyMMddHHmmssSSS, where the later part should be substituted by the current time every time the test runs.
I am thinking that I should write a groovy script for this. Could any one please suggest how this can be written?

Thank you,
Soaprookie

1 Reply

  • Hi,
    Use following groovy:

    String generateUsername(String user)
    {
    date = new Date().format('yyMMddHHmmssSSS')
    user = user + "_ " + date
    }
    user = generateUsername("anyuser")
    log.info user

    Hope it helps.