testing library
Test utilities for dust_server.
import 'package:dust_server/testing.dart';
void main() {
test('lists todos', () async {
final client = TestClient(buildApp());
addTearDown(client.close);
(await client.get('/todos').send())
..assertOk()
..assertJsonContains({'count': 0});
});
}
TestClient(router)— in-process, no socket, sub-millisecond.TestClient.serve(router)— real HTTP on port 0, catches wire bugs.
Separate from server.dart so production code never pulls test utilities.
Classes
- TestClient
- Drives a Router through either an in-process handler or real HTTP.
- TestRequest
-
A request being built for a
TestClient. - TestResponse
-
The response from a
TestClientrequest.
Functions
Exceptions / Errors
- TestAssertionError
-
Extends Error so
package:testtreats it as a test failure without depending onpackage:test.