Skip to main content
Breakdance is built on a simple philosophy: Test Real Things. Traditional mocking creates a parallel universe where your tests pass but your code might still fail in production. Mocks require you to maintain fake implementations that can drift from reality. They obscure real problems and introduce artificial complexity. Snapshots are different. They capture actual HTTP traffic from real APIs and replay it in your tests. Your tests exercise the same code paths, parse the same JSON structures, and handle the same edge cases as production. When the real API changes, your snapshots reveal the difference immediately.

What Are Snapshots?

Breakdance uses the term “snapshot” to describe captured HTTP traffic that can be replayed during testing:

Why Snapshots Beat Mocks

AspectTraditional MocksSnapshots
Source of truthDeveloper imaginationReal API behavior
MaintenanceManual updates requiredRe-capture when API changes
AccuracyProne to driftAlways reflects reality
Edge casesOften forgottenNaturally captured
Test confidence”Works with mocks""Works with real data”
DebuggingArtificial scenariosReal-world scenarios

The Snapshot Workflow

1

Capture

Record real HTTP traffic from the actual API. This happens once per endpoint or when the API changes.
  • For requests: Copy from browser DevTools, API docs, or write .http files
  • For responses: Run your code against the real API with capture enabled
2

Store

Check snapshot files into source control alongside your tests. They become part of your test fixtures.
3

Replay

Tests read from snapshot files instead of making network calls. Fast, deterministic, and offline-capable.
4

Refresh

When APIs change, re-capture snapshots. Your tests immediately reveal any breaking changes.

When to Use Each Type

Request Snapshots (.http files)

Use request snapshots when you want to:
  • Document API contracts in a readable format
  • Share request examples with your team
  • Test multiple variations of the same endpoint
  • Chain requests together (login → get profile → update settings)
  • Use environment-specific variables (dev/staging/prod URLs)
users.http
@baseUrl = https://api.example.com

### Get all users
GET {{baseUrl}}/users
Accept: application/json

### Get specific user
GET {{baseUrl}}/users/123
Accept: application/json

Response Snapshots

Use response snapshots when you want to:
  • Test against third-party APIs without hitting rate limits
  • Run tests offline or in CI environments without API access
  • Ensure deterministic test data (same response every time)
  • Test error handling with captured error responses
  • Avoid polluting real accounts with test data
// Responses served from files, no network calls
var handler = new ResponseSnapshotReplayHandler("Snapshots");
var client = new HttpClient(handler);

var response = await client.GetAsync("https://api.example.com/users");
// Response loaded from Snapshots/api.example.com/users.json

Combining Both Approaches

The real power comes from combining request and response snapshots:
public class UserApiTests : DotHttpTestBase
{
    protected override HttpMessageHandler CreateHttpMessageHandler()
    {
        // Replay captured responses
        return new ResponseSnapshotReplayHandler("ResponseSnapshots");
    }

    [TestMethod]
    public async Task GetUsers_ReturnsExpectedData()
    {
        // Request defined in .http format
        SetVariable("baseUrl", "https://api.example.com");

        var request = new DotHttpRequest
        {
            Method = "GET",
            Url = "{{baseUrl}}/users"
        };

        // Request format from .http, response from snapshot file
        var response = await SendRequestAsync(request);

        await DotHttpAssertions.AssertValidResponseAsync(response);
    }
}
This gives you:
  • Readable requests in .http format with variables and chaining
  • Real responses captured from actual API calls
  • Fast execution with no network overhead
  • Deterministic results for reliable CI/CD

Getting Started

PackagePurpose
Breakdance.DotHttpRequest snapshots via .http file parsing
Breakdance.AssembliesResponse snapshot handlers