Forum Discussion
sentrt86
2 years agoOccasional Contributor
Can you please share the snippet of how you did? thanks for your response.
- KarelHusa2 years agoChampion Level 1
I am sharing a Groovy snippet, see bellow.
The principle is:
- Take SoapUI/ReadyAPI libraries (see imports)
- Follow the same approach you would use with ReadyAPI user interface, i.e., create a project, create test suite, create test case, add test step, set assertions.
The snippet only illustrates the principles, but cannot be executed as is, since it is extracted from a larger project.
import com.eviware.soapui.impl.WsdlInterfaceFactory import com.eviware.soapui.impl.wsdl.WsdlInterface import com.eviware.soapui.impl.wsdl.WsdlProject import com.eviware.soapui.impl.wsdl.WsdlTestSuite import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase import com.eviware.soapui.model.project.Project import groovy.xml.* List services = getServices() def projectName = "SharedServices-GeneratedTests" def project = new WsdlProject() project.setName(projectName) services.each { def service = it WsdlInterface[] interfaces = WsdlInterfaceFactory.importWsdl(project, getServiceWSDL(service), true)[0] WsdlTestSuite suite = project.addNewTestSuite(service) WsdlTestCase tc = suite.addNewTestCase("BasicTest") tc.setFailOnError(false) WsdlGroovyScriptTestStep gs = tc.addTestStep(GroovyScriptStepFactory.GROOVY_TYPE, 'SetRequestId') gs.setScript('testRunner.getTestCase().setPropertyValue("RequestId", UUID.randomUUID().toString())') WsdlTestRequestStep step = ServiceTest.createTestStep(interfaces[0], tc, 'StandardRequest', getServiceRequest(service)) step.addAssertion('Not SOAP Fault') step.addAssertion('Schema Compliance')
Related Content
Recent Discussions
- 22 days ago