Forum Discussion

klusht's avatar
klusht
Occasional Contributor
13 years ago

Script library plus function class

Hi all ,
I need to make my scripts world wide available , and I need to find a nice way to make the scripts available for anyone in a less effort approach, and also be flexible enough.

I created a jar file with a class full of static functions, and after I deploy it in ext folder, I can use those like valx = new functions.F(log).time() ( package functions , class F with constructor F(log4j.Logger log) to be used in the class , and method time() ).
But it is ugly, and I need to initialize this class ( functions.F(log) ) under a nicer shorter name, like context.setProperty("f", new functions.F(log)) ( then to be used as context.f.time()).
So I nee a place where to put this initialization step, and where soapUI executes this line at sturt-up , or before lunching each the testRunner.

I've try ed to put in the project "custom property" something like :addFunctions = ${=context.setProperty("f", new functions.F(log))} but is not executed by default, so is available only if I run this statement inside the testStep.

Can you suggest me a second place where I can put statements that are run before each test step...

Also , is there a way to put a script precondition IN the testStep. like an "pre assertion"
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Hi,

    Have you tried it by having your script in Setup Script [ This will be available when you double click on a project --> bottom side of TestSuites Tab ] ?
    Copy initialization code there. Hope this helps.

    Regards,
    Rao.
  • saraflores's avatar
    saraflores
    New Contributor
    Hi!

    How would you do it? Do you mean in properties? How do you have your script in Setup Script?

    I tried several ways to create a "global script library" using .jar, a project with all reusable code and instaces and using the Script folder in SoapUIPro. And no method works. I couldn't do it at least.
    Any suggestion?

    Thanks in advance and sorr for the inconvenience.

    Regards,

    Sara.