i don't have any background in development especially in java.
I would like to learn how to read and use SoapUI API from SoapUI API docs (http://www.soapui.org/apidocs/index.html?overview-summary.html)
something like testRunner, context, messageExchange.
how do i know which method or which variable i can use for i.e context variable, testRunner variable
usually i see someone write like
or something like
where i can get this information?
I would like to understand how people know they can user expand in the context variable etc
Solved! Go to Solution.
This obviously isn't a complete answer, just my personal view and before learning about SoapUI, Groovy scripting and writing a book about it, I had a lot of Java / API / frameworks experience, but I would say the online help docs can be quite useful and was where I started e.g.
Basically I learned by example, created lots of Groovy Test Steps and had a good hack about to learn how to extract / insert data to and from objects, requests and responses...
Also, there are various blogs etc and was one book at the time.
I never did the certification, not sure how much scripting is in that, possibly someone else could say?
Any specific examples / explanataions of variables / scripts, then let me know...
Though the question is too generic, but it is near to my heart as I was in the same situation when I started using it.
Initially, started searching on the net. Sometimes, lucky to get the info what was needed then and sometimes may not.
On one fine day, had happened to watch the video https://www.youtube.com/watch?v=92WEfVJPJDQ
And started more thurst from there.
Hope you too get the benefit out of it.
Hi Rupert, nmrao
many thanks for your reply, also watching the youtube vid.
actually my biggest confusion is related with the path, class and available method.
Like in above youtube vid for 2nd webinar, they write
I am trying the same syntax in groovy test step and got error no such property workspace for class
i know in teststep groovy there is variable log, context, testRunner,
still i don't know the method i can use for each of them
i am trying
got error can not get property methods
i am trying
got below result
[equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait, cancel, fail, getLog, getReason, getRunContext, getStartTime, getStatus, getTestRunnable, getTimeTaken, isRunning, setRunContext, start, waitUntilFinished, getResults, getRunContext, getTestCase, gotoStep, gotoStepByName, runTestStep, runTestStepByName, setMockRunContext]
still i am confuse, usually when i am googling some script, people write like this
from above metaClass result i can't find after testRunner i can write testRunner.testCase.
how does people know about this?
In the video, it is explained how one can explore the soapUI API.
Below is groovy script test step.
If you notice above, below variables are accessible:
log, context, testRunner.
Now, if you want to know details about testRunner variable, then just have the following statement in the groovy step and execute it, so that you would know what is the type of this variable
You may see below output
Sun Nov 08 00:10:13 IST 2015:INFO:com.eviware.soapui.impl.wsdl.panels.support.MockTestRunner@43810d51
Now open the class MockTestRunner in soapui's api docs where you can see the allowed methods on testRunner say getTestCase().
As you mentioned, testRunner.testCase and testRunner.getTestCase() are same. testRunner.testCase is groovified version(ignores explict get and paranthesis). Other one is java way.
So, like above, you can find any object's class and look into api docs to get the methods.
And similarly, if you see the project load script, test suite setup, teardown and test case setup and teardown (all of them or groovy type ) different variables available and are mentioned like how we see for groovy step.
Thanks nmrao, very clear explanation, i am started to understand how to read the API document.
would like to ask you agan:
log.info testRunner.testCase.testSuite.project.workspace.getProjectByName("myProject").testSuites["yourTestSuite"].testCases["TestCase 1"].testSteps["delete"].testRequest.responseContentAsXmlis there any possibility to shortened above script?
log.info testRunner.testCase.testSuite.project.workspace.getProjectByName("myProject").testSuites["yourTestSuite"].testCases["TestCase 1"].testSteps["delete"].run(testRunner, context)but i can not understand what is the meaning from (TestCaseRunner runner, TestCaseRunContext runContext) inside run method.
Like, context.testCase.name and context.getTestCase().getName() are same and here there are no arguments involved.
Similarly set also, however, it mostly may contain some argument.
How to set a test case property
But it will be little different if there are arguments to be passed for either set and get methods.
Can also be expressed as
context.testCase.properties['PROPERTY_NAME'].value = 'PROPERTY_VALUE'
How to get a test case property
At least, above are some variants of set / and get methods while using groovified.
2. Gald know that.
If you want to access artifacts from other test suite, one must at least have project object(by accessing it successive parents). Here, you went one level ahead i.e., workspace which is not required.
Get the project object :
def currentProject = context.testCase.testSuite.project
Then use currentProject later for all references if you dont want to use it long.
ite"].testCases["TestCase 1"].testSteps["delete"].testRequest.responseConten tAsXml
#3 one is also same as above.
Many thanks nmrao for you explanation
if my understanding are correct, context and testRunner have same meaning?
when i should use context and when i should use testRunner?
hopefully you're not get boring with my question
Context is defined at project, test suite, and test case levels. So object can vary depending upon where it is being accessed. And similarly TestRunner.
To your question, both are not same, testRunner is member variable of context object. Applies to all levels.
thanks nmrao for very long explanation, got better understanding now on API and context & testRunner variable