Execute JDBC teststep using Groovy in SOAPUI

2019-08-20 12:12发布

问题:

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

回答1:

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"


回答2:

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.