Forum Discussion

codehausss's avatar
codehausss
Contributor
9 years ago
Solved

SoapUI scripting with Eclipse - is it possible?

As i know we can add external library to Java project when working with Selenium webdriver on Eclipse.

 

Is it possible to do the same for SoapUI?

I am trying to create Groovy project on Eclipse and add soapui-5.2.0.jar file (from SoapUI\bin folder) into project extenal libray but doesn't work :(

 

I just want to use Eclipse for write the scripting so it can help me for autocompletion or error before i copy paste groovy script to SoapUI test step

 

am i missing something when adding external library?

  • nmrao's avatar
    nmrao
    9 years ago
    1. parseText() method is of JsonSlurper class. However, the package is different. Use the following to get it right
      import net.sf.json.groovy.JsonSlurper
    2.  You should be able to use SoapUI's API, however, should be aware that soapui invokes / maintains certain objects when it is started.
    • For eg: If you open any groovy script, you would see certain variables like testRunner, context, log on the top of the script editor.
    • Similarly, if you open setup script of testSuite, you would see runner, context, log etc.
    • And in the script assertion, you would see messageExchange, context, log etc.
    • So, if you need these variables in your class, your methods accessing these variables should have them as parameters. Then you would be able to access them without any issue.
    /**
    * this example class is a user class which access soapUI variables
    **/
    import com.eviware.soapui.model.iface.MessageExchange
    public class TestAssertion {
      public boolean myScriptAssertion(MessageExchange messageExchange) {
      /// do the stuff
      }
    }
    

    And the above class needs to be called from your script assertion like

    def myTestAssertion = new TestAssertion()
    log.info myTestAssertion.myScriptAssertion(messageExchange)

    Please revert back if you have any question.

6 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Can you please clarify - "but it doesn't work"?
    If you can show the script, that will help.
    By the way, Intellij IDEA is the best for groovy projects, in my opinion.
    • codehausss's avatar
      codehausss
      Contributor

      Hi nmrao

       

      I mean it doesn't display the autocompletion for SoapUI specific method or keyword.

      Here what am i doing with eclipse

      - create Groovy Project and soapui-5.2.0.jar via Add External JARs

      soap3.jpg

       

      - doesnt detect parseText method

      soap1.jpg

       

      - doesnt detect soapUI method or keyword

      soap2.jpg

       

      with the same step to add external library, i am able scripting selenium with eclipse and showing autocompletion and selenium method or keyword.

      selenium1.jpg

       

       

       

      what should i do to be able to use eclipse for soapUI scripting before i copy the scripting to soapUI test step or assertion?

      i just want to leverage eclipse autocompletion/intellisense for soapUI specific method/keyword without digging into soapUI api documentation.

      • shakor's avatar
        shakor
        Occasional Contributor

        Yeah I am doing that. I just create an empty project in eclipse and then add all the jars under <soap_ui_root>/lib and the soapui-xxx.jar under <soap_ui_root>/bin. 

         

        I think you are not doing the first step. You probably don't need all the jars under the lib folder but I added them anyway.

         

        EDIT: I think it is the groovy-all-xxx.jar that have the JsonSlurper class but that should be provided by the Eclipse Groovy libraries as well so not sure what your issue is.