木吟

导航

Get teststep of specific type

SoapUI Groovy : Check if test step is of specific type, such as : Wsdl, Rest, Jdbc, HTTP, Groovy etc

import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep
import com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep
import com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequestStep

if (step instanceof WsdlTestRequestStep) {
    log.info "Found a request step of Wsdl/Soap type"
} else if (step instanceof RestTestRequestStep) {
    log.info "Found a request step of Rest type"
} else if (step instanceof JdbcRequestTestStep) {
    log.info "Found a request step of jdbc type "
} else if (step instanceof HttpTestRequestStep) {
    log.info "Found a request step of http type " 
}


SoapUI Groovy: Get all test steps of specific type

import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep

def testSuiteList = testRunner.testCase.testSuite.project.getTestSuiteList()
for(testSuite in testSuiteList){
    testCaseList = testSuite.getTestCaseList()
    for(testCase in testCaseList){
        testStepList = testCase.getTestStepsOfType(RestTestRequestStep)
        for (testStep in testStepList){
            testStepName = testStep.name
        }
    }
}

 

posted on 2019-03-15 13:06  木吟  阅读(164)  评论(0编辑  收藏  举报