Forum Discussion

tofurkey's avatar
tofurkey
New Contributor
14 years ago

beginner issues help wanted

Hello everyone,

Really awesome free product you have here and I see great flexibility in using testscript to control and do fancy stuff with your web services. I have been testing both the pro version and the community one. I am sticking to the free one so far but the pro has a nice interface that makes things easier.

I have a few start-up issues:

1) I am unfamiliar with the dot notation of the SoapUI documentation
- I see the following line often "testRunner.testCase.testSuite.project" and I try to understand how this dot notation works in scripting with Groovy. Where do I find the docs for the properties/methods for these testRunner, testCase, testSuite and etc. Is this part of groovy's api documentation or is this entirely SoapUI's? I've been checking api docs for both groovy and soapUI, but I fail to find any relevant information

2) In my wildest dream I would like to do some simple testing for a REST api.
- I got the service, method and resource defined
- I created a testsuite, added the request to a testcase
- now I want to write a simple script to create a unique name for my REST api parameter
- put unique string in a property; transfer this property to the REST api request as a parameter - (this is where I am struggling; I don't know how to access the return values from the REST api script-wise. In the automated scripting feature (pro) that you have, the argument provided there is named messageExchange something and everything works great there; but it's only available when using the cool automated scripting feature)
- retrieve the return output that's in JSON and parse it
- do some simple assertion on the JSON return output
- do some logging on fail/success
- profit?

You guys rock with this great tool. I would love to hear from you soon and thank you for your time,

tofurkey

5 Replies

  • Hi there. Welcome to soapUI forums!

    Here are a few hints.

    1. The dot notation is syntax that is common to several scripting/programming languages (see here: http://en.wikipedia.org/wiki/Method_chaining). Maybe you are familiar with this already? Basically the line you've given means "Access the testRunner object, access that object's parent testCase, access that object's testSuite parent, access that object's project object.
    Here are relevent API doc pages with Method summaries that show methods you can call on these objects.
    project: http://www.soapui.org/apidocs/com/eviwa ... oject.html
    testSuite: http://www.soapui.org/apidocs/com/eviwa ... Suite.html
    testCase: http://www.soapui.org/apidocs/com/eviwa ... Suite.html
    testRunner: (presumably a TestCaseRunner in your case) http://www.soapui.org/apidocs/com/eviwa ... unner.html

    2. One advantage of the Pro version is the extra UI interfaces that help you write fancy assertions and test steps. Some of these things can be done in the free version if you just learn how it's done in the Pro version and then manually do it in the free version. Have a look at creating an XPath assertion in the Pro version. The Pro version provides tools to generate XPath queries for you that access specific XML elements. In the Pro version, look at the 'Outline' view of your Response. Right-click on a returned XML element/value. Choose "Create assertion for..."
    Also read this blog post on Script Assertions: http://groovyinsoapui.wordpress.com/200 ... n-soap-ui/

    Hope this helps some.
  • tofurkey's avatar
    tofurkey
    New Contributor
    thank you for your reply and taking the time digging up links. it is very much appreciated.
  • andrewlaser's avatar
    andrewlaser
    Occasional Contributor
    Hello Unhandled,
    Thanks for you help.

    As all scripts are invoked with "log", "context" and "testRunner" variables, could you give a hint where find documentation for them?

    BTW, as tofurkey wrote, testRunner has property "testCase", but in the documentation for TestCaseRunner "testCase" property is not mentioned http://www.soapui.org/apidocs/com/eviwa ... unner.html

    Thanks,
    Andrew
  • andrew_laser's avatar
    andrew_laser
    Occasional Contributor
    The only way I found to find out API docs is the following:
    e.g. for context
    1)
    log.info(context.getClass() ) //get class name
    //got: Thu Sep 08 11:13:28 EEST 2011:INFO:class com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext

    2)
    Search for its API documentation in http://www.soapui.org/apidocs/ or at apache.org for "log", or wherever

    Does anybody know any better solution? Preferably with autocomplete.
  • Gilbeeert's avatar
    Gilbeeert
    New Contributor
    I really like your writing style, excellent info , appreciate it for putting up : D.