Skip to main content
Breakdance provides multiple approaches for testing web APIs, each suited to different scenarios. Choose based on your testing needs:

Choose Your Approach

Quick Comparison

FeatureIn-MemoryRequest SnapshotsResponse Snapshots
Network callsNoneOptionalCaptured
Test speedFastestFastFast (cached)
Real API testingNoYesInitial capture
Offline capableYesWith snapshotsYes
Request chainingManualBuilt-inN/A
Environment configsN/AYesPer-folder

Combining Approaches

These techniques work well together. See the Snapshots Overview for the full philosophy.
// Use .http file format with captured response snapshots
public class ApiTests : DotHttpTestBase
{
    protected override HttpMessageHandler CreateHttpMessageHandler()
    {
        // Serve responses from snapshot files
        return new ResponseSnapshotReplayHandler("ResponseSnapshots");
    }

    [TestMethod]
    public async Task GetUsers_Test()
    {
        SetVariable("baseUrl", "https://api.example.com");

        var response = await SendRequestAsync(new DotHttpRequest
        {
            Method = "GET",
            Url = "{{baseUrl}}/users"
        });

        await DotHttpAssertions.AssertValidResponseAsync(response);
    }
}

Guides

PackagePurpose
Breakdance.WebApiIn-memory Web API 2 testing on .NET Framework
Breakdance.AspNetCoreIn-memory ASP.NET Core testing with TestServer
Breakdance.DotHttp.http file parsing and test base class
Breakdance.AssembliesResponse snapshot handlers