Forum Discussion

krishna4's avatar
krishna4
Occasional Visitor
4 years ago

Groovy script to start REST mock

Hi,

 

I found the below script to start and stop SOAP mock service. My requirement is to count the no.of hits for the mock and stop it once the hits count reach 3. The below script works fine to SOAP mock. But for rest mock this script doesn't work. Any idea how to start and stop REST Mock services using groovy script? I am aware of starting and stopping via maven plugin but it doesn't fir my requirement as I need to get the mock running count in my test steps.

 

def runner = testRunner.testCase.testSuite.project.mockServices["PFLUploadWebServiceMockService"].start()
runner.clearResults()
log.info "mock service started"


def runner = testRunner.testCase.testSuite.project.mockServices["PFLUploadWebServiceMockService"].getMockRunner()
assert runner.isRunning() == true
int resultCount = 0;
while(resultCount<3)
{
resultCount = runner.getMockResultCount()
log.info "result count : " + resultCount
}
runner.stop()
log.info "mock service stopped"

No RepliesBe the first to reply