Forum Discussion

codehausss's avatar
codehausss
Contributor
10 years ago

How to read and use SoapUI API for non Dev people?

Hello,

 

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

 

context.expand

or something like

testRunner.testCase.testSuite

 

where i can get this information?

I would like to understand how people know they can user expand in the context variable etc

 

many thx

  • nmrao's avatar
    nmrao
    9 years ago

    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.

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

     Hi,

     

    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.

    http://www.soapui.org/scripting---properties/tips---tricks.html

     

    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...

     

    Cheers,

    Rupert

    • nmrao's avatar
      nmrao
      Champion Level 3

      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 thirst 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

    println workspace

    .
    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

    log.info context.metaClass.methods*.name


    got error can not get property methods

    i am trying

    log.info testRunner.metaClass.methods*.name


    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

    testRunner.testCase.testSuite...



    from above metaClass result i can't find after testRunner i can write testRunner.testCase.
    how does people know about this?

    • nmrao's avatar
      nmrao
      Champion Level 3

      In the video, it is explained how one can explore the soapUI API.

       

      Below is groovy script test step.

      Selection_253.png

       

      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 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.

      • codehausss's avatar
        codehausss
        Contributor

        Thanks nmrao, very clear explanation, i am started to understand how to read the API document.

         

        would like to ask you agan:

         

        1. Only "get" followed by "parantheses" i can ommit from method name, is it correct?
        2. I am able to access another teststep inside another test suite using
          log.info testRunner.testCase.testSuite.project.workspace.getProjectByName("myProject").testSuites["yourTestSuite"].testCases["TestCase 1"].testSteps["delete"].testRequest.responseContentAsXml
          is there any possibility to shortened above script?
        3. I am able to run another teststep inside another test suite using
          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.
          What is the function of testRunner and context inside this method?

         

        regards,

         

  • infomaven's avatar
    infomaven
    Occasional Contributor

    I enjoyed reading through this thread.  This is a classic approach that can work for learning any kind of software language; not just Groovy, and the participants showed professionalism and respect for each other. The Forum met its purpose!