简体   繁体   中英

Execute JDBC teststep using Groovy in SOAPUI

I am trying to execute JDBC teststep using Groovy in SOAPUI

def Proj = null
def workspace = testRunner.testCase.testSuite.project.getWorkspace();
Proj= workspace.getProjectByName("<ProjectName>")   
def ProjTestCase = Proj.testSuites["["<TestSuiteName>"].testCases["
<TestCaseName>"]
def DBTestStep = ProjTestCase.getTestStepByName("Get_10_DBValues")
def runner = null
runner = DBTestStep.run(testRunner, context)
log.info(DBTestStep)
runner = null

I gives me following output INFO:com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep@7f34840b

See below line to run your soap UI project using cmd or store into batch file and run batch file

cd C:\Users\%username%\SmartBear\SoapUI-Pro-5.1.2\bin\

cmd.exe /C testrunner.bat -a -j -f"<localPathForReportStoring>" -R"JUnit-Style HTML Report" -EDefault "<LocalPath>\ProjectName.xml"

Referring to your comment, Since your groovy script is within the project>testsuite>testCase, you cannot trigger your groovy script alone, externally. However, you can enable only your groovy script and disable all other test steps. When you run the project/testcase, your groovy will execute and call other steps explicitly. SOAPUI will not run disabled steps by its own.

import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
def DBTestStep = ProjTestCase.getTestStepByName("Get_10_DBValues")
def runner =  new WsdlTestRunContext(DBTestStep)
DBTestStep.run(testRunner, runner )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM