Stubby4j best tool for testing interactions with web services

Recently while searching for some tool for testing web services,I came across Stubby4j ,it is highly flexible and configurable tool for testing interactions of SOA applications with web services (REST, SOAP, WSDL etc.) over HTTP(S) protocol. It is an actual HTTP server (stubby4j uses embedded Jetty) that allows stubbing of external systems with ease for integration, contract & behavior testing.

Stubb4j Utility
Image – Stubby4j Utility

Stubby4j has following advantages over other tools:

  1. You can simulate responses from real servers
  2. Allows invocation of service call for services which are not ready yet or in-accessible due to various reasons.
  3. Simulates support for different types of HTTP authentication.
  4. Enables delayed responses for performance and stability testing

Key features

  • Emulate external webservice in a SANDBOX for your application to consume over HTTP(S)
  • HTTP request verification and HTTP response stubbing
  • Regex support for dynamic matching on URI, query params, headers, POST payload (ie:. mod_rewrite in Apache)
  • Dynamic token replacement in stubbed response, by leveraging regex capturing groups as token values during HTTP request verification
  • Record & Replay. The HTTP response is recorded on the first call, having the subsequent calls play back the recorded HTTP response, without actually connecting to the external server
  • Dynamic flows. Multiple stubbed responses on the same stubbed URI to test multiple application flows
  • Fault injection, where after X good responses on the same URI you get a bad one
  • Serve binary files as stubbed response content (images, PDFs. etc.)
  • Embed stubby4j to create a web service SANDBOX for your integration test suite

Why would a developer love it ?

  • Simulate responses from real server and don’t care (or cannot) to go over the network
  • Third party web service your application suppose to contract with is not ready yet
  • Verify that your code makes HTTP requests with all the required parameters and/or headers
  • Verify that your code correctly handles HTTP error codes
  • You want to trigger response from the server based on the request parameters over HTTP or HTTPS
  • Support for any of the available HTTP methods
  • Simulate support for different types of HTTP Authorizations: Basic, Bearer Token & others
  • Support for HTTP 30x redirects
  • Provide canned answers in your contract/integration tests
  • Enable delayed responses for performance and stability testing
  • Avoid to spend time coding for the above requirements
  • Concentrate on the task at hand

QA use cases stubby4j?

  • Specifiable mock responses to simulate page conditions without real data.
  • Ability to test polling mechanisms by stubbing a sequence of responses for the same URI
  • Easily swappable data config files to run different data sets and responses.
  • All-in-one stub server to handle mock data with less need to upkeep code for test generation

System requirements 

  • version >= 4.0.0: Oracle JRE v1.8.0_60
  • version >= 3.0.0: Oracle JRE v1.7.0_76
  • version = 2.0.22: Oracle JRE v1.7.0_04
  • version < 2.0.22: Oracle JRE 1.6.0_65-b14-462

Quick start :

Quick Start

  1. Download the latest stubby4j version (the JAR archive).
  2. Create the following local YAML file:
-  request:
      method: GET
      url: /hello-world
      status: 200
         content-type: application/json
      body: Hello World!
  • Execute the downloaded stubby JAR using command java -jar stubby4j-x.x.xx.jar -d <PATH_TO_YOUR_CREATED_LOCAL_YAML_FILE>
  • Navigate to http://localhost:8882/hello-world to get the stubbed response “Hello World!”
  • Navigate to stubby4j admin portal at http://localhost:8889/status to see what has been stubbed & other useful data

Like this post? Don’t forget to share it!

Article Name
Stubby4j flexible and configurable tool for testing interactions with web services
Highly flexible and configurable tool for testing interactions of SOA applications with web services
Publisher Name

Average Rating

5 Star
4 Star
3 Star
2 Star
1 Star

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Previous post Avidemux free video editor designed for simple cutting, filtering and encoding tasks
school Next post Enroll now : 11 Popular courses