Introduction

🌐 Stoobly is a feature-rich man-in-the-middle proxy tool to record and mock HTTP/HTTPS requests and responses.

🚀 Easily create scalable API mocks with little setup time.

⚡ Maintaining hard-coded inputs and responses is expensive. De-clutter your codebase and streamline maintenance with replay and record.

💡 Upon request interception, mocking is configurable to match against all request components.

🔨 Need advanced configuration? Take advantage of features like scenarios, filters, rewriting, match rules, and lifecycle hooks.

Why Mock APIs?

Roughly an additional 50% of time spent in development is needed for testing and validation. This includes writing unit, integration and end-to-end testing as well as the mocks to support them.

Mocking out APIs results in more reliable and faster tests.

Tests that make requests to upstream APIs can suffer from intermittent failures due to updates or downtime. Because upstream APIs can also call other APIs, depending on live services tend to make tests slow.

Having flaky and slow tests means more time is spent debugging and less time spent on core features.

Current State of API Mocking

While many tools exist for API mocking, most are suited for more trivial integration tests or don't offer enough features to cover more advanced use-cases.

Several classes of API mocking tools include:

Below we summarize creating and maintaining API mocks using the above solutions.

Creation

Creating the initial API mocks are an upfront time cost by Software Engineers and QA Engineers.

The following lists challenges with creating API mocks and highlights existing solutions:

  1. Creating realistic response stubs

    • Hard-coding responses

    • Use of faker libraries

  2. Precisely matching requests with responses

    • Using strict or pattern-based URL matching to map requests to responses

    • Headers and bodies are not taken into account

Maintenance

Maintenance is a variable time cost by Software Engineers and QA Engineers. Every time the request or response contract changes, mocks have to be modified. This becomes a time-consuming process as more and more API endpoints are added. Time spent maintaining scales exponentially with the number of request variations.

The following lists challenges with maintaining mocks and highlights existing solutions:

  1. Determining which requests and responses need updating

    • Work with service maintainers

    • Audit change logs of upstream API changes

    • Wait for tests that depend on an out-of-date response to fail

  2. Updating mock request variations with up-to-date parameters and/or responses

    • Manually copy/paste or edit the request and/or response

How Stoobly Helps

Creation

Stoobly makes creating mocks fast and accessing them precise.

The following lists challenges with mocking and highlights how Stoobly can help:

  1. Creating realistic response stubs

    • Mocking APIs built from recorded requests

    • Rewrite any part of the request to filter sensitive data

  2. Precisely matching requests with responses

    • Matching based on URL, bodies and/or headers

Maintenance

Stoobly helps minimize the impact of having to maintain mocks.

The following lists challenges with maintaining mocks and highlights how Stoobly can help:

  1. Determining which requests and responses need updating

    • Shared maintenance, updates by producer can immediately be accessed by consumers

  2. Updating mock request variations with up-to-date parameters and/or responses

    • Support replaying requests and recording the responses

    • Group a sequence of requests into scenarios and batch replay and record

To learn more see our Generating Mock APIs use case!

Last updated