Server Testing Overview
server_testing is the foundation for HTTP and full-stack testing across the routed ecosystem.
It layers fluent assertions, transport adapters, and browser automation on top of the test package so you can exercise an application end to end inside your normal Dart test suite.
Packages in This Guide
server_testing: core library that ships the HTTP client, response assertions, transports, browser APIs, CLI, Mockito helpers, and a built-inIoRequestHandlerfordart:ioapplications.server_testing_shelf: first-party adapter that turns a Shelf handler into aRequestHandler.routed_testing: ready-made handler providers for the routed framework, built on top of the same primitives.
What You Can Test
- HTTP & API tests — run fast, in-memory requests or spin up an ephemeral
HttpServerand assert on the real wire format. - Browser flows — launch Chromium or Firefox through WebDriver, interact with the UI via a high-level
BrowserAPI, and capture logs/screenshots. - Page objects — model screens and reusable components via the provided
PageandComponentbase classes. - Custom servers — adapt any framework by implementing the lightweight
RequestHandlerinterface. - Mock-level tests — construct
MockHttpRequest,MockHttpResponse, and header/URI helpers for isolated unit tests.
Core Building Blocks
RequestHandlerbridges your app/framework to the testing runtime. ImplementhandleRequest,startServer, andclose.IoRequestHandleris a built-in implementation fordart:ioHttpServerapplications—no framework required.serverTestwraps a standardtest()and automatically manages aTestClientlifecycle.TestClientsends HTTP requests through either the in-memory or ephemeral server transports.TestResponseexposes fluent status/headers/body/JSON assertions plus debugging helpers likedump().BrowserConfig,browserTest, andbrowserGrouporchestrate WebDriver-backed UI automation with optional device profiles.server_testingCLI installs browser bundles, drivers, and scaffolds test directories.
Where to Go Next
- Brand new? Start with Getting Started to install dependencies and write your first test.
- Testing APIs? See HTTP Testing and the detailed TestClient guide.
- Need a framework adapter? Read Handler Providers.
- Running UI flows? Combine Browser Testing with the BrowserConfig options and Pages & Components.
- Installing tooling? The CLI covers browser bundle and driver management.