Ask a Question

Access testRunner objects from external jar files


Access testRunner objects from external jar files

Hi all,


Has anyone tried accessing testrunner objects from external jar file?


I have same properties in all testcases.I want to see if i can access property based on run context from jar file.Also,I want to be able to access the test step from external file. I could only think of jar file but not sure how to go about it.





Community Hero

Yes, you can use the api to call the external classes from groovy script. Only thing is that you need to pass the variables that are available in the groovy script such as log, context, testRunner to the user class, so that one would be able to access these variables in his classes


Implement your class(es), compile and build the jar file, then put it under SOAPUI_HOME/bin/ext and restart the SoapUI / Ready!API.


In your groovy script, just create the object of your class, like you do in java, then call the methods as you wish.


Here is an example class:



/** * below is a groovy class example demonstrates * how to access the soapui objects * inside user class **/ package demo.external.classes SoapUIDemoClass { def context def log def testRunner def greet(def name) { "Hello, ${name}" } def showTestCaseName() { "Name of the test case is : ${}" } def getTestCasePropertyValue(def name) {[name].value } }


Here is how you can call the above class methods in groovy script:


import demo.external.classes.SoapUIDemoClass

//Instaniating your class object with constructor def demoClass = new SoapUIDemoClass(context: context, log: log, testRunner: testRunner) //Call the method of user class
//Getting the test case property value using a method defined in user class def value = demoClass.getTestCasePropertyValue('ANY_PROPERTY_THAT_YOU_HAVE') "Property value is : ${value}"
//logging the name of the test case from method of user defined class.


Thank you Rao,But which IDE did you use to code and compile ?

While writing above? Not used any. If your question is in general, you may use intellij/eclipse whatever you like.

Showing results for 
Search instead for 
Did you mean: