Jul 5, 2012

Incrementing test case property value using groovy script


def curJobId = testRunner.testCase.getPropertyValue( "JobIdIncre" );
int curJob=Integer.parseInt(curJobId);
def jobId = context.expand( '${#TestCase#JobID}' )
//Composing the JodId for this event
def returnJobID=jobId+curJob;
//Incrementing the JobID for next event
curJob=curJob+1;
testRunner.testCase.setPropertyValue( "JobIdIncre",curJob.toString() );
return returnJobID;

1 comment:

  1. Hi Prasad

    Thanks for sharing this script.
    I need to increment account numbers and this is working fine as long as the length of account no. is 9 digits.
    For a 10 digit account no.,it is throwing an error
    java.lang.NumberFormatException:For input string:"3101000021" error at line 2.

    Could you please help me with this?

    Thanks.

    ReplyDelete