cancel
Showing results for 
Search instead for 
Did you mean: 

Testing Groovy Scripts Locally

michaeljohn82
Participant
0 Kudos

Dear All,

I've gone through numerous blogs, but they're outdated and haven't been helpful in testing Groovy scripts locally using IntelliJ. I'm hoping to get some assistance. Can someone provide guidance on testing a basic Groovy program that includes all classes from the package com.sap.gateway.ip.core.customdev.util including AttachmentWrapper and SoapHeader? I attempted to simulate the message class with support from the book of vadim.klimov and engswee.yeoh, but I'm eager to learn how to do the same for other classes. Is it possible to set up a full simulation environment for Groovy on our laptops using IntelliJ? Any help would be greatly appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

MortenWittrock
Active Contributor

Hi Michael

I haven't been following this closely, so I cannot comment on how to run your scripts locally. I will add an opinion about testing them, though.

Two things are happening in an SAP Cloud Integration script:

  1. Interaction with the platform (like calling methods on the Message object to get the payload, set a property etc.)
  2. Your actual logic (like parsing a JSON object, extracting some values from it and doing a calculation on them)

I would argue that you can't really test the former locally anyway. You might be able to approximate the runtime environment, but you won't know for sure until your code actually executes in the real runtime environment.

You can test the latter locally, though. You just need to structure your script around this distinction, so that you, for instance, perform that JSON parsing in a separate method. Such a method can then be unit tested locally using existing Java and Groovy tools.

Your testing in SAP Cloud Integration can then focus on the platform interaction, which is likely also much simpler than the main logic of your script.

Anyway, just my two euro cents on the topic 🙂

Regards,

Morten

michaeljohn82
Participant

Hi Morten - Thank you for the help. Yes, I will think about this and also some more options.