0
votes

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

3
Have you tried by defining JDBC Test Step? - Rao
@Rao, Thanks for reply. I was able to get and working... I have another question, how do I run only a groovy script (my script contains Test cases to execute) from command line...? - luckyvasul
You can use SOAPUI_HOME/bin/testrunner.bat or .sh to run command line. - Rao
I want to run only a Script (which my script will execute all test steps in a Testcase), How can mention to execute only a groovy script from command line ? - luckyvasul

3 Answers

0
votes

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"
0
votes

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.

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