Eviware Forum

soapUI => soapUI => Topic started by: zxsoap on June 17, 2008, 11:08:47 pm



Title: Create Groovy library?
Post by: zxsoap on June 17, 2008, 11:08:47 pm
Hi All,

I want to create a Groovy library. Anyone tried it yet? Please, let me know.  I'm able to create a Java class, not Groogy scripts?

Thanks,
Tim


Title: Re: Create Groovy library?
Post by: zxsoap on June 20, 2008, 03:54:03 pm
All,

Here's my groovy scrip look like and I want to share it by all my testcases. Is it possible to create a library to hold it. I want to use it like a function library. I tried to create a java class but got the issue with import eviware....

groovyUtils = new com.eviware.soapui.support.GroovyUtils(context )
holder = groovyUtils.getXmlHolder ("searchTempT#Response")
def nname= holder.getNodeValues ("//name") 

for (n in nname)
{
 println n
}

Thanks,
zx


Title: Re: Create Groovy library?
Post by: omatzura on June 23, 2008, 11:39:47 pm
Hi!

soapUI Pro has the functionality required for this: http://www.soapui.org/userguide/scripting.html#Groovy_Script_Library.

If you are not using soapUI Pro you will need to compile your scripts into a standard java library (ie .jar file) and add that file to the classpath by putting it in the bin\ext folder..

regards!

/Ole
eviware.com


Title: Re: Create Groovy library?
Post by: zxsoap on July 01, 2008, 03:50:13 pm
Hi Ole,

Thank for you helps. Yes, I want to build groovy library class ( I used 2.0.2 Pro). I have an issue how to use "testRunner.testCase.name". I did include "import com.eviware.soapui.model.testsuite.TestRunner". But it could get a test case name (null value) at run time.

Here's what I want to do. I want to build a class which's going to get the test case name and write to text file at run time. I'm using  "testRunner.testCase.name". But have issue with it. Here's the I tried to build (not 100% complete yet)



package soapui.Report

import com.eviware.soapui.SoapUI
import com.eviware.soapui.model.testsuite.TestRunner

public class Rwrite
{
   
   
public void  fw ()
   {
     TestRunner testRunner
 
    println "TestCase: " + testRunner.testCase.name
   
}

Did I do something wrong? why testRunner.testCase.name's always return  NULL.

Thanks,
zx


Title: Re: Create Groovy library?
Post by: omatzura on July 01, 2008, 11:12:26 pm
Hi!

you'll need to pass the testRunner as an argument to your fw method.. ie

Code:
..
public void fw( Object testRunner )
{
...
}

...

hope this helps!

regards,

/Ole
eviware.com


Title: Re: Create Groovy library?
Post by: zxsoap on July 07, 2008, 09:22:07 pm
Hi Ole,

It's still return Null as I used the following code.

public class Rwrite
{
   
   
public void  fw (TestRunner testRunner)
   {
       
    println "TestCase: " + testRunner.testCase.name
   }

}

Thanks,
zx


Title: Re: Create Groovy library?
Post by: omatzura on July 08, 2008, 08:55:17 am
Hi!

how are you using the Rwrite class from your scripts? Can you show the code?

regards!

/Ole
eviware.com


Title: Re: Create Groovy library?
Post by: zxsoap on July 08, 2008, 05:32:40 pm
Ole,

Here's my code used under Grooyy script. (If I remove the "testRunner.testCase.name" under println. It's working ok.)


def wReports = new soapui.Report.Rwrite()
wReports.fw ()

Here's class with .groovy

package soapui.Report
public class Rwrite
{
   import com.eviware.soapui.model.testsuite.TestRunner
   
public void  fw (TestRunner testRunner)
   {
       
    println "TestCase: " + testRunner.testCase.name
   }

}


Thanks,
zx




Title: Re: Create Groovy library?
Post by: omatzura on July 08, 2008, 11:24:42 pm
Hi,

I think you need to pass the testRunner as an argument.. ie

def wReports = new soapui.Report.Rwrite()
wReports.fw ( testRunner )

regards!

/Ole
eviware.com


Title: Re: Create Groovy library?
Post by: zxsoap on July 09, 2008, 02:55:27 pm
It worked...thank alot.