Forum Discussion

streamerd's avatar
Occasional Contributor
7 years ago

Problem with saving/creating REST TestRequests as project (in Java)



Recently I've successfully developed a method that uses wsdl endpoint and saves the SOAPUI project file.


Our purpose is to create these project documents for the endpoints with custom request contents,then run regularly on some remote machine that have SOAPUI installed.


However, for the REST part, I've done many things but could not make it work to add test step(s) to the test case.


I am not sure if followed the right practice, yet I can see that there is a testStep under the testRequestList.



My code is as follows (also attaching one of the failure projects):




TestCaseConfig testCaseConfig = restConfiguration.getTestCaseConfig();
WsdlProject wsdlProject = new WsdlProject();

RestServiceBuilder serviceBuilder = new RestServiceBuilder();
serviceBuilder.createRestService(wsdlProject, url);
WsdlTestSuite wsdlTestSuite = wsdlProject.addNewTestSuite("Suite");
WsdlTestCase wsdlTestCase = new WsdlTestCase(wsdlTestSuite, testCaseConfig, false);
RestService restService = (RestService) wsdlProject.getInterfaceList().get(0);
RestResource restResource = restService.getOperationAt(0);
RestRequest requestx = restResource.getRequestAt( 0 );
TestStepConfig testStepConfigx = RestRequestStepFactory.createConfig(requestx, "Step");
wsdlTestCase.insertTestStep(testStepConfigx, -1);


No RepliesBe the first to reply