WebTestClient
Spring's reactive web test client for testing Spring WebFlux endpoints with fluent assertions.
Pricing
Free / Open source
Type
Automation
Languages
Java, Kotlin
// VERDICT
Reach for WebTestClient when you're testing Spring WebFlux or MVC endpoints and want a fluent, in-framework client with no external server. Skip it when you're not on Spring or want a standalone API-testing tool.
Best for
Spring's reactive, fluent client for testing WebFlux and Spring MVC endpoints - in-framework HTTP testing without a running server.
Avoid when
You're not on Spring, or you want a standalone or GUI API client.
CI/CD fit
JUnit · Maven · Gradle · Spring Boot Test · GitHub Actions
Languages
Java · Kotlin
Team fit
Spring/JVM teams · Backend SDET teams · Reactive (WebFlux) teams
Setup
Maintenance
Learning
Licence
// BEST FOR
- Testing Spring WebFlux and Spring MVC endpoints from within the framework
- Binding directly to the application context - no running server needed
- A fluent request/exchange/expect assertion style
- Reactive, non-blocking testing aligned with WebFlux
- Living inside Spring Boot test slices alongside other Spring tests
- Asserting status, headers and JSON bodies fluently
// AVOID WHEN
- Your application isn't built on Spring
- You want a standalone or GUI API client
- You need to test arbitrary external APIs, not your Spring app
- Non-Spring teammates must own the tests
- Cross-language contract testing is the goal (Pact)
- You want a tool decoupled from the Spring test lifecycle
// QUICK START
# Add spring-boot-starter-test, bind WebTestClient to the context, then:
./gradlew test// ALTERNATIVES TO CONSIDER
| Tool | Choose it when |
|---|---|
| REST Assured | You want a framework-agnostic Java API-testing DSL. |
| OkHttp3 | You want a general-purpose JVM HTTP client rather than a Spring test client. |
| SuperTest | You're in JS/Node rather than the JVM. |
// FEATURES
- Fluent API for sending requests and asserting responses
- Native support for reactive WebFlux endpoints
- Bind to a controller, application context, or running server
- JSON path and XPath response body assertions
- Integrates with Spring Boot test slices
// PROS
- First-class for Spring WebFlux testing — no extra dependencies
- Reactive types (Mono/Flux) handled natively
- Works with both mock and real server modes
- Tight integration with @WebFluxTest
// CONS
- Spring-specific — irrelevant outside the JVM Spring world
- Steeper than REST-assured for non-reactive APIs
- Documentation assumes Spring familiarity
// EXAMPLE QA WORKFLOW
Add the Spring Boot test starter
Bind WebTestClient to the application context or a controller
Write fluent request/exchange/expect assertions
Cover status, headers and JSON body expectations
Keep tests in Spring Boot test slices
Run in the normal Maven/Gradle test step in CI
// RELATED QA.CODES RESOURCES
Cheat sheets
Glossary
Interview