Forum Discussion
Cizo89
12 years agoFrequent Contributor
Hi Prakash,
I'll try to explain my situation.
I have a SoapUI project with several REST Service resources and couple of TestSuites (with many TestCases and TestSteps).
All service calls from our platform are being logged to db and I want to create a Groovy script which will create a new TestCase with REST TestSteps (based on the data from the database - requests, urls, userId and etc.)
I know the service, resourcePath and method, but I can't create the service, all my attemps so far ended in the "Missing REST Resource for TestRequest" window.
I know how to create new TestSuite/TestCase dynamically via Groovy, so that's not a problem, but I don't know how to successfully create a REST TestRequest without being asked to linked the new REST TestRequest to one of my resources.
I think the best way for creating new REST TestRequest is class RestRequestStepFactory and its methods buildTestStep(WsdlTestCase testCase, TestStepConfig config, boolean forLoadTest) and createNewTestStep(RestMethod restMethod, String name).
To create a new instance of RestMethod I have to create new instances of classes RestResource and RestService (or use method addNewResource(String name, String path) in RestService / addNewMethod(String name) in class RestResource).
But it doesn't matter if I try it in one way or the other way, in the end I always have to link the new REST TestRequest to one of my already exisiting resources.
I think the problem is in the config classes, because when I amend them to match SoapUI standards, the constructor from above class won't reflect it so all attributes such as service, resourcePath, method, type and etc. are thrown away.
Here is a piece of my code (sorry, I had to remove some confidential details such as ServiceName or ResourcePath)
Regards,
Marek
I'll try to explain my situation.
I have a SoapUI project with several REST Service resources and couple of TestSuites (with many TestCases and TestSteps).
All service calls from our platform are being logged to db and I want to create a Groovy script which will create a new TestCase with REST TestSteps (based on the data from the database - requests, urls, userId and etc.)
I know the service, resourcePath and method, but I can't create the service, all my attemps so far ended in the "Missing REST Resource for TestRequest" window.
I know how to create new TestSuite/TestCase dynamically via Groovy, so that's not a problem, but I don't know how to successfully create a REST TestRequest without being asked to linked the new REST TestRequest to one of my resources.
I think the best way for creating new REST TestRequest is class RestRequestStepFactory and its methods buildTestStep(WsdlTestCase testCase, TestStepConfig config, boolean forLoadTest) and createNewTestStep(RestMethod restMethod, String name).
To create a new instance of RestMethod I have to create new instances of classes RestResource and RestService (or use method addNewResource(String name, String path) in RestService / addNewMethod(String name) in class RestResource).
But it doesn't matter if I try it in one way or the other way, in the end I always have to link the new REST TestRequest to one of my already exisiting resources.
I think the problem is in the config classes, because when I amend them to match SoapUI standards, the constructor from above class won't reflect it so all attributes such as service, resourcePath, method, type and etc. are thrown away.
Here is a piece of my code (sorry, I had to remove some confidential details such as ServiceName or ResourcePath)
import com.eviware.soapui.impl.wsdl.teststeps.registry.RestRequestStepFactory
import com.eviware.soapui.impl.rest.RestMethod
import com.eviware.soapui.impl.rest.RestResource
import com.eviware.soapui.impl.rest.RestService
import com.eviware.soapui.config.RestMethodConfig.Factory
import com.eviware.soapui.config.RestResourceConfig
import com.eviware.soapui.config.RestServiceConfig
RestRequestStepFactory rest = new RestRequestStepFactory()
def project = testRunner.testCase.testSuite.project
def restServiceConfig = RestServiceConfig.Factory.newInstance()
restServiceConfig.setType("restrequest")
RestService restService = new RestService(project, restServiceConfig)
restService.setName("test")
RestResource restResource = restService.addNewResource(serviceName, resourcePath)
RestMethod restMethod = restResource.addNewMethod("POST")
rest.buildTestStep(testRunner.testCase, rest.createNewTestStep(restMethod, "test"), false)
Regards,
Marek
Related Content
- 13 years ago
- 2 years ago
- 6 years ago
Recent Discussions
- 19 days ago