Skip to main content

WireMock integration

Note:
  • Please note that the use case presented here is a suggestion only and should be implemented with caution. It has not undergone quality assurance testing and is not officially supported by our platform.

Katalon Studio integrates with WireMock, a leading provider of mocking services that delivers both an open source version as well as a cloud version. With WireMock Cloud, Katalon users will be able to easily mimic a production API's behavior for end to end testing even if the production API is not yet developed or available. These virtualized services (otherwise known as service virtualization) can then be shared and used across teams without additional effort or maintenance.

Virtualizing a service enables Katalon users:

  • to build test assets even when the APIs you need aren't ready or released.
  • to guard against unstable 3rd party API's when developing tests to reduce test flakiness
  • to simulate edge cases and faults easily, to help with unhappy path testing.

How to Integrate Katalon with WireMock Cloud

To integrate Katalon Studio with WireMock Cloud, you need to follow these steps:
  • WireMock Cloud offers a free forever edition as well as paid plans for enterprises. You will need to create a WireMock Cloud account to leverage WireMock with Katalon.

  • Verify the response of the WireMock API: In your Katalon test script, you need to verify the response of the WireMocked API to ensure that it meets your expectations.

  • You can do this by using the API testing and Verification Validation mechanisms to check the status code, headers, and response body of the HTTP response.

  • Call the WireMocked API in your test: In your Katalon test script, you need to call the WireMocked API to verify the behavior of your system under test. You can do this by making HTTP requests using the WebUI.callRestApi method in Katalon.

  1. Navigate to Settings on WireMock Cloud. You will see a mock service.WireMock settings
  2. In this example, we will use a sample API from the internet.sample API
  3. There are several ways to create a mock service in WireMock Cloud:
    • Manually via the web UI
    • Swagger or OpenAPI specification import
    • Record traffic to and from another API
    • Import an existing project from WireMock
    • Automate via the REST API or WireMock

    The below screenshot shows how to use recording in order to create a sample stub within the mock service created in Wiremock. You can also watch a video demonstration.

  4. Once the real API service is recorded you can observe that multiple stubs are created with all the responses captured during the recording.WireMock stubs
  5. Once recorded, we head to Katalon studio and create a new web service request and hit the mock API service which was recorded using Wiremock Cloud.create a new web service in Katalon Studio
  6. We now run the sample request and observe that the responses are from the MockAPI vs the real API service.Katalon Studio run sample request
  7. We can now create an API test within Katalon and compare using verification and validation mechanism.Katalon Studio create API testKatalon Studio compare