Forum Discussion

HimanshuTayal's avatar
HimanshuTayal
Community Hero
7 years ago

Structuring Groovy

Hello Members,

 

Is there any way in ReadyApi or any other tool out there where i can structure my unstructured Groovy Code in Groovy Script or Script assertion

  • Hi there,

     

    By structure do you mean format/beautify (auto indentation)

    This is possible with xml forms using the shortcut Alt + f

     

     

    As for structuring Groovy, you can use external editors such as sublimetext3 which can open your entire project filesystem, or you can copy and paste your scripts into here to be formatted

     

    To add the formatting functionality click preferences -> key bindings

    Then in the keymap.User window (should be the blank window on the right) copy and paste this

     

    [
    	{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}
    ]

     

     

    This allows you to format with the shortcut Alt + Shift + f. One thing to note: When you copy and paste your groovy code over make sure you click view -> syntax -> groovy.

     

    Example:

     

    Before

    After

     Hope this helped,

    Mo

     

    • HimanshuTayal's avatar
      HimanshuTayal
      Community Hero

      And i hope it won't send any information or code anywhere wlse online.

       

      Coz by using this i want to format my companies code and it won't be allowed to use these open-source softwares to be installed on local machine.

       

      Thanks,

      Himanshu Tayal

      • MoUddin's avatar
        MoUddin
        Contributor

        It is an offline text editing program, similar to notepad - check with your admin team if they can install it for you.

         

        But to answer your original question, no I don't think ReadyAPI or SoapUI have any built in groovy formatter, I'm sure you could suggest it as a new feature

         

        All the best,

        Mo

         

        EDIT: I see you already have here haha, best of luck with that :smileyhappy: