← All features

Testing

Unit testing for scripts

Setting up unit tests for SAP Cloud Integration Groovy scripts takes boilerplate code and test data that nobody has time to write.

Unit testing for scripts lets integration developers test the Groovy scripts in their SAP Cloud Integration iFlows without writing the test setup themselves. Figaf DevOps Suite reuses the test cases you already recorded for an iFlow and turns them into test data and unit tests for its scripts. It is part of the Figaf Testing Tool, and it is bundled with the Git integration so developers can run and debug scripts in their own IDE.

How it works

  • Generate from test cases. If you have created test cases for an iFlow in Figaf, you select “Generate Groovy Scripts Test data”. Figaf creates test data for all the scripts in that iFlow.
  • JSON test data. Each input and output message, with its headers, properties and body, is written as a JSON file in the Git repository. This lets Figaf create automated assertions of all the parameters in the message.
  • Generated test class. Figaf creates a JUnit test method for each script in the flow, linked to its test messages. You can remove the scripts you do not want to test, and exclude parameters from the comparison with getIgnoredKeys.
  • Add more data over time. Each time you generate, Figaf adds more test data with an increasing number, so you can extend coverage as new test cases are recorded.
  • Custom assertions. Besides comparing input with expected output, you can send a message through the script and write your own assertions, for example with AssertJ soft assertions.
  • Mock services. The repository contains mock implementations of the services a script needs, so scripts run without connecting to them. You add the SAP Cloud Integration jars yourself. Since it is a mock, some exotic functions may not behave exactly as on the tenant, so you should still test in SAP Cloud Integration.
  • In Figaf too. In Figaf’s own Groovy and XSLT editor, you pick a test case as input, run the script on your tenant and compare the output with the expected result from the test case.
  • In the pipeline. Unit tests can run in a Git pipeline, such as GitHub Actions, and a failing result is shown on the transport.
A Groovy script for SAP Cloud Integration in IntelliJ, with the Figaf Git folder structure and failed unit tests
Generated unit tests run in your own IDE
Figaf Groovy editor with a test case selected as input, the script, and the output panel
Run a script against a test case in the Figaf editor

Business value

  • Faster fixes. Developers can run a script against real test data in seconds, instead of deploying the iFlow and sending a message for every attempt.
  • Fewer regressions. Every script change can be checked against the messages it handled before, so unexpected changes in output are caught early.
  • Less effort to build tests. The test setup and test data are generated, so teams get unit tests without spending time on boilerplate code.
  • Knowledge kept in tests. The behavior of each script is recorded in test data that the whole team can run, not only the developer who wrote it.

Good to know

  • Unit testing for scripts is part of Figaf DevOps Suite and the Figaf Testing Tool, and works with the Git integration.
  • Release 2604 removed Figaf’s Gradle plugins from the public Git repository, since they are no longer maintained.
  • Related features: Git integration, Groovy editor with AI assistance and regression testing.

Learn more

Included in

Figaf DevOps Suite

Unit tests for your Groovy scripts, generated from test cases you already have

Reuse the test cases recorded for an iFlow to create unit tests and test data for every Groovy script in it, so developers can run and debug their changes quickly.

See unit testing for scripts on your landscape

No credit card required.

Integration cost calculator →

Start your free trial

No credit card required

Try Figaf DevOps Suite free for 30 days. It takes less than an hour to get started, and we send everything you need by email.

Join our newsletter

Get the latest about Figaf, SAP and anything relevant to SAP integration, every week in Figaf Weekly.