Forum Discussion

jonrey's avatar
jonrey
Occasional Contributor
9 years ago

How to tell what a command returns?

Hello all,

 

Novice at SoapUI coding, so apologies if this is a stupid question.  Haven't been able to find an answer in the Help, though.

 

Is there a way to tell exactly what a command is returning?  For example, if I create a custom property and then call it in a Request, it just gives me an error.  It would be very helpful if there were a tool I could use to tell exactly what the return of the command is instead.

 

Example command: ${=String.valueOf('2014-'&'(Math.Random() * (12 - 01) + 01)'&'-01')}

 

Thank you!

1 Reply

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    There are no stupid questions... :-)

     

    When I want to see the value of a Groovy expression in SoapUI I usually just:

     

    1) Create a Groovy TestStep

     

    2) In the Groovy TestStep use log.info and run it e.g.

     

    def now = new Date()
    log.info now.format("yy-MM-dd")

     

    Gives log output in the TestStep of

     

    • Thu May 21 20:24:27 UTC 2015:INFO:15-05-21

    Other options are to create a Groovy Class in Eclipse (good for building up more complex Groovy scripts, as you get intelli-sense), also the Groovy Console, which can also be used as a SoapUI plugin (more on this please ask).

     

    By the way in your example command, & doesn't concatenate strings/text in Groovy, you can use + instead.

     

    Hope this helps,

     

    Cheers,

    Rup