Ask a Question

how to increment date for each test run

SOLVED
Nancy2
Occasional Contributor

how to increment date for each test run

Hi,

 

In my test step I need to pass new date in each test run. How can I do that?

 

Regards,

Preeti

28 REPLIES 28
avidCoder
Super Contributor

In that case, the code which I have shared should work fine, considering that you can control the limit of the execution.

nmrao
Champion Level 3

@Nancy2 ,

 

In your test case, place below a Groovy Script test step before the Request test step, so that it can generate the next date and also remembers the same for next time not to generate the duplicate date.

 

Selection_029.png

 

And in the request, use <element>${#TestCase#NEW_DATE}</element>

 

Here is the text of the above script

https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/date/CreateNewDate.groovy

 

Doesn't require any additional libraries.



Regards,
Rao.
Nancy2
Occasional Contributor

Hi,

 

Sorry for the delayed response.

 

I hope this solution will work. As of now I am facing issue while implementing this. I have done below steps -

1. In the test step example "Register TestCase"

2. Click on Insert Step > Groovy script and named as "NDate"

3. Copied the script given

4. Within "Register TestCase", For Date input parameter, added - ${#Register TestCase#NDate}

5. Ran Groovy script

6. Ran Register

At this time, getting error as - "String was not recognized as a valid DateTime."

What can be the reason for above error?

 

Regards,

Preeti

 

 

Nancy2
Occasional Contributor

Hi,

 

Sorry for the delayed response.

 

I hope this solution will work. As of now I am facing issue while implementing this. I have done below steps -

1. In the test step example "Register TestCase"

2. Click on Insert Step > Groovy script and named as "NDate"

3. Copied the script given

4. Within "Register TestCase", For Date input parameter, added - ${#Register TestCase#NDate}

5. Ran Groovy script

6. Ran Register

At this time, getting error as - "String was not recognized as a valid DateTime."

What can be the reason for above error?

 

Regards,

Preeti

 

New2API
Frequent Contributor

Hi preeti, when referencing a test case property you need not to explicitly mention the testcase name if property is being called in the same testcase.

so your reference should be ${#TestCase#NDate}

 

thanks!

Nancy2
Occasional Contributor

Can I get help on this query??

nmrao
Champion Level 3

What happened to the reply provided on "13-02-2019 06:03 AM"? Have you tried at least? What is the update?


Regards,
Rao.
Nancy2
Occasional Contributor

I have done extactly the same steps as mentioned. But getting error - String was not recognized as a valid DateTime.

nmrao
Champion Level 3

Error log please? Screen shot of the script and test case would help.


Regards,
Rao.
Nancy2
Occasional Contributor

 
cancel
Showing results for 
Search instead for 
Did you mean: