cancel
Showing results for 
Search instead for 
Did you mean: 

,Using groovy script to run rest api test suite.How can i add delay between test test cases

Occasional Contributor

,Using groovy script to run rest api test suite.How can i add delay between test test cases

Hi,

i am using groovy script to run my REST API test suite and want to put delay for few test cases but not sure how and where.For Eg. test case name is verify password , reconcile password and verify password again.

So want to put delay between reconcile password and verify password again Bz reconile password test case takes time to perform the reconcilation of password where we have to wait for 2-3 minutes atleast .

 

Below is the groovy script that i m using :

def testcases = testRunner.testCase.testSuite.getTestCaseList()
// for all testCases in your test suite...
testcases.each { testcase ->
    // for all testStep inside testCase...
    def teststeps = testcase.getTestStepList()
    mylist = ['https://wevet16742.ms.ds.uhc.com']
  
    for(i in mylist)
    {
 
     teststeps.each { teststep ->
        teststep.setPropertyValue('endpoint',i)
        endpoint = teststep.getPropertyValue('endpoint')
        if(!teststep.getName().equalsIgnoreCase("RunAllTestCase"))
        {
 
         def r = teststep.run(testRunner, context)
         log.info(endpoint)
        log.info "RUNNING Service :: ${testcase.getName()} -> ${teststep.getName()}"
         log.info "RESULT :: ${r.getStatus()}"
         log.info "---------------------------------------------------------------"
       
      
        }
    }
   
    i++
    }
    
    }

 

 

 

thanks,

6 REPLIES 6
Super Contributor

Re: ,Using groovy script to run rest api test suite.How can i add delay between test test cases

You can use Thread.sleep(3000) between the codes. You can try this link also for better sleep codes in groovy: -

https://mrhaki.blogspot.com/2016/10/groovy-goodness-interrupted-sleeping.html?_sm_au_=iVVqNk1JRTH16l...

Highlighted
Community Hero

Re: ,Using groovy script to run rest api test suite.How can i add delay between test test cases

Why is it required to run the tests using grooy?
The best practice would be:
Use testrunner utility (from SOAPUI_HOME/bin) and pass the project.
Please refer documentation
https://www.soapui.org/test-automation/running-from-command-line/functional-tests.html


Regards,
Rao.
Occasional Contributor

Re: ,Using groovy script to run rest api test suite.How can i add delay between test test cases

I m using groovy bz running test suite on multiple servers .

Community Hero

Re: ,Using groovy script to run rest api test suite.How can i add delay between test test cases

Can you try the command line way?
YOu can use project level custom property for the server name port and pass the value from command line.
No groovy is required.


Regards,
Rao.
Occasional Contributor

Re: ,Using groovy script to run rest api test suite.How can i add delay between test test cases

Hi nmrao,

Can u pls elaborate it more?

 

Community Hero

Re: ,Using groovy script to run rest api test suite.How can i add delay between test test cases

It is clearly available in the documentation, please take a look.

1. command line options link has been provided in the earlier reply.
2. On the properties, refer below:
https://www.soapui.org/scripting-properties/working-with-properties.html
https://www.soapui.org/docs/functional-testing/properties/working-with-properties.html


Regards,
Rao.