This is a project to make it easier to test applications built using Axum, using full E2E tests.
Examples
You can find a thorough example in the /examples folder.
Features
You can start a webserver running your application, query it with requests, and then assert the responses returned:
use Router;
use get;
use TestServer;
async
async
The TestServer will start on a random port, allowing multiple servers to run in parallel.
That allows tests to be run in parallel.
This behaviour can be changed in the TestServerConfig, by selecting a custom ip or port to always use.
Request building
Querying your application on the TestServer supports all of the common request building you would expect.
- Serializing and deserializing Json and Form content using Serde
- Cookie setting and reading
- Access to setting and reading headers
- Status code reading and assertions
- Assertions for defining what you expect to have returned
Remembers cookies across requests
axum-test supports preserving Cookies from responses,
for use in follow up requests to same TestServer.
This is similar to how a browser will store cookies from requests,
and can help with tests where you need to authenticate first.
This is off by default, and can be enabled in the TestServerConfig by setting save_cookies to true.