Creating TestCases and TestSteps dynamically in a Groovy step
We are trying to integrate with a project management software for test case development. We have a way of feeding the test results into this software so it will auto pass/fail the test case.
Some of our test cases are just configuration, 10's, 100's, 1000's permutations of the same method. We want the test case names in SoapUI to be unique, representing the values that are being sent in the operation. The only way I can think of doing this without having to manually create hundreds of test cases is to create them with a groovy script, run them, and delete them.
I found some code for creating a test case but no examples of adding a wsdl test step.
import com.eviware.soapui.config.TestStepConfig import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepFactory def newTestCase = suite.addNewTestCase("NewTestCase") def newTestStep = newTestCase.addTestStep('testStep')
The problem is the addTestStep() wants a type from what I can tell here https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/testcase/WsdlTestCase.html
I don't know what to put in the String type. I've found examples of other test step types being created so I tried to kinda copy that structure and nothing is working.
Also, I made the name of this thread a little off topic from the body because I am also interested if anyone has done this kind of thing before and maybe has a better solution or ideas.
Thanks!
I think you're after a "request" from these:
public static final String AMF_REQUEST_TYPE "amfrequest" public static final String DELAY_TYPE "delay" public static final String GOTO_TYPE "goto" public static final String GROOVY_TYPE "groovy" public static final String HTTPREQUEST_TYPE "httprequest" public static final String JDBC_TYPE "jdbc" public static final String JMS_STEP_ID "JMS" public static final String MANUAL_TEST_STEP "manualTestStep" public static final String PROPERTIES_TYPE "properties" public static final String TRANSFER_TYPE "transfer" public static final String RESTREQUEST_TYPE "restrequest" public static final String RUNTESTCASE_TYPE "calltestcase" public static final String MOCK_RESPONSE_TYPE "mockresponse" public static final String REQUEST_TYPE "request"
I got that from this page and section https://www.soapui.org/apidocs/constant-values.htl#com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory.GROOVY_TYPE
But to be honest I never would have found that without looking through the source code.
It looks like if you try creating it from just the type, you're going to get prompted every time for which Operation the request is going to be on. So you'll need to figure out how to call addTestStep and pass in the rest of the information it needs. (One idea: what about cloning an existing test step?)