While testing REST APIs for one of my projects, I found REST Assured. It was perfect, as it took care of low level HTTP calls under the hood, and provided a high-level, easy to use framework to write tests. Not only REST Assured works really well to test webMethods flow services, you can also run these tests as part of Continuous Integration process through Gradle.
You will need following things on your machine. Make sure these are working without any issues.
We will write automated tests for a simple flow service that adds two numbers.
Follow following steps to create automated tests.
Open IntelliJ IDEA and create a new project
Add following lines in your build.gradle file
Create new package for our test cases
Create new Java class for our tests.
Here we are just taking advantage of Integration Server’s built in content handler for Content Type - ‘application/json’. For the flow service available on Integration Server, we can simply pass JSON request using REST Assured framework. Integration Server will take care of converting this to IDoc and subsequently process it to return a JSON response back to your test case.
- Run the tests using Gradle wrapper
Gradle wrapper provides a convenient and easy to use CLI to run your tests. Using Gradle wrapper you can quickly associate your REST Assured tests with your Continuous Integration process.
Good thing about using REST Assured and Hamcrest to test your webMethods flow services is, it is completely FREE. You don’t need to buy an expensive automated testing solution to test your flow services.
Further resources to read