Keploy logo
ASP.NET Core logo

Keploy as a ASP.NET Core testing framework

Keploy tests ASP.NET Core applications by recording real requests through Kestrel and every EF Core query or HttpClient call they trigger, then replaying both as assertions. There is no WebApplicationFactory to build and no service registration to override.

Generate ASP.NET Core tests free
keploy record -c "dotnet Orders.dll"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a ASP.NET Core team

Any ASP.NET Core app, unchanged

Keploy runs the assembly you publish. Minimal APIs, MVC controllers, Razor Pages, and gRPC endpoints all record the same way, because capture happens at the socket rather than inside the middleware pipeline.

  • .NET 6 and above
  • Minimal APIs, MVC, and Razor Pages
  • Kestrel or behind a reverse proxy
  • Startup and hosted services run
The problem

Why ASP.NET Core integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing ASP.NET Core: by hand, with xUnit + WebApplicationFactory, or with Keploy

WebApplicationFactory boots the pipeline with registrations swapped out. Keploy records the running Kestrel process, so middleware, auth, and the real DI graph all execute.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for ASP.NET Core vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
OrdersEndpointTests.cs
hand-written
// Hand-written: the handler is called past the pipeline.
using Xunit;
 
public class OrdersEndpointTests
{
[Fact]
public async Task ConfirmsAnAuthorizedOrder()
{
var repo = new FakeOrderRepository();
var payments = new FakePaymentClient("AUTHORIZED");
 
var result = await OrderEndpoints.Confirm(
"ord_1", new ConfirmRequest("tok_123"), repo, payments);
 
var ok = Assert.IsType<Ok<OrderView>>(result);
Assert.Equal("CONFIRMED", ok.Value!.State);
}
}

Fast, and authentication, model binding, and the exception handler registered in Program.cs never run — so an unreachable endpoint still passes.

xUnit + WebApplicationFactory1–2 hours
OrdersIntegrationTests.cs
tool-assisted
// xUnit + WebApplicationFactory + service overrides.
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
 
public class OrdersIntegrationTests : IClassFixture<WebApplicationFactory<Program>>
{
private readonly HttpClient _client;
 
public OrdersIntegrationTests(WebApplicationFactory<Program> factory)
{
_client = factory.WithWebHostBuilder(b => b.ConfigureTestServices(s =>
{
// The real payment client never runs in this test.
s.AddSingleton<IPaymentClient>(new FakePaymentClient("AUTHORIZED"));
s.AddDbContext<OrdersDb>(o => o.UseInMemoryDatabase("test"));
})).CreateClient();
}
 
[Fact]
public async Task ConfirmsAnAuthorizedOrder()
{
var res = await _client.PostAsJsonAsync(
"/orders/ord_1/confirm", new { paymentToken = "tok_123" });
 
Assert.Equal(HttpStatusCode.OK, res.StatusCode);
}
}

Drives the real pipeline — and both the payment client and the database are replaced, so the two integrations this test is named for never happen.

With Keploy~5 minutes
test-1.yaml
auto-generated
# Recorded with: keploy record -c 'dotnet Orders.dll'
# Real Kestrel. Real DI graph. No overrides.
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
req:
method: POST
url: /orders/ord_1/confirm
header:
Authorization: Bearer <captured>
body: '{"paymentToken":"tok_123"}'
resp:
status_code: 200
body:
id: "ord_1"
state: "CONFIRMED"
amountMinor: 4200
confirmedAt: "2026-09-02T11:04:18Z"
noise:
- body.confirmedAt
mocks:
- kind: SQL
operation: "SELECT [o].[Id], [o].[AmountMinor], [o].[State] FROM [Orders] AS [o] WHERE [o].[Id] = @__id_0"
- kind: Http
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm

The auth middleware authorised this request and EF Core translated a real query — neither of which a test host with overrides exercises.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

ASP.NET Core testing tools, compared

The options a team on .NET actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your ASP.NET Core app once, replay it forever

Keploy sits below your ASP.NET Core process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a ASP.NET Core service and captures the dependency calls it makes.

ASP.NET Core logo
Your ASP.NET Core app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+3 more ASP.NET Core dependencies
An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

What Keploy mocks for ASP.NET Core, with zero config

7 of the 7 dependencies a typical ASP.NET Core service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.

Quick start

Your first ASP.NET Core test suite in under five minutes

Every command below runs against your existing ASP.NET Core service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "dotnet Orders.dll"
  3. 3Exercise the paths you care about

    Publish as normal, then drive the running app. Every request becomes a test case with its EF Core queries and HttpClient calls captured alongside.

    dotnet publish -c Release -o out
    curl -X POST localhost:5000/orders/ord_1/confirm -H 'Content-Type: application/json' -H 'Authorization: Bearer $TOKEN' -d '{"paymentToken":"tok_123"}'
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "dotnet Orders.dll" --delay 12

Ready to try it on your own ASP.NET Core service?

Ecosystem

Works with the rest of your ASP.NET Core stack

Keploy records at the network layer, so framework and driver choices inside your ASP.NET Core app do not change how it captures traffic.

FAQ

ASP.NET Core testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.