We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
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.
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
log.info testRunner
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 https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/panels/support/MockTestRunner.html 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 (http://www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestCaseRunner.html runner, http://www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestCaseRunContext.html runContext) inside http://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/teststeps/RestTestRequestStep.html#run%28com.eviware.soapui.model.testsuite.TestCaseRunner,%20com.eviware.soapui.model.testsuite.TestCaseRunContext%29method.
regards,
#1. Yes.
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.
context.testCase.setPropertyValue('PROPERTY_NAME','PROPERTY_VALUE')
Can also be expressed as
context.testCase.properties['PROPERTY_NAME'].value = 'PROPERTY_VALUE'
How to get a test case property
context.testCase.getPropertyValue('PROPERTY_NAME')
or
context.testCase.properties['PROPERTY_NAME'].value
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.
currentProject.testSuites["yourTestSuite"].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.