Forum Discussion

Dchen's avatar
Dchen
Occasional Contributor
7 years ago
Solved

Groovy Script using bat file

Hi, 

 

I am using a bat file in a Groovy step and I get the folllowing results (see attachment).

--> INFO: MXM-AUS-1720-0018

 

How can i put this string ( MXM-AUS-1720-0018) into a property so i can use it in my API testing.

Or maybe I can use it with "Get data" Groovy script result?

 

Regards,

Donny

 

  • Hi,

     

    Setting your value into a property is very simple and can be done in at least 2 ways: directly from the groovy script or using a special 'Property Transfer' step. I personally prefer the first one because it takes no extra steps thus the tests remain cleaner.

     

    Hands-on: Let's say you have a test case property defined as in the photo below:

     

     

    In order to save the value of the code in the 'CodeValue' property your groovy script would look like this:

     

     

    Please let me know if you need more help. :)

2 Replies

  • Lucian's avatar
    Lucian
    Community Hero

    Hi,

     

    Setting your value into a property is very simple and can be done in at least 2 ways: directly from the groovy script or using a special 'Property Transfer' step. I personally prefer the first one because it takes no extra steps thus the tests remain cleaner.

     

    Hands-on: Let's say you have a test case property defined as in the photo below:

     

     

    In order to save the value of the code in the 'CodeValue' property your groovy script would look like this:

     

     

    Please let me know if you need more help. :)

    • Dchen's avatar
      Dchen
      Occasional Contributor

      Hi Lucian,

       

      I am really new to Groovy, so your "simple" explanation worked perfectly for me :)

       

      Thx!

      Donny