Anarchy.Toolkit.Testing.Web
Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Testing kit · Package catalog
Test helpers for REST APIs using the toolkit’s web pipeline.
dotnet add package Anarchy.Toolkit.Testing.Web
- Derive from
RestApiTestCaseBase<TStartup, TAppSettings>to exercise native and AWS Lambda request pipelines. TestableLambdaEntrypointsupports Lambda-based tests;MockAuthorizationToken<TAppSettings>(scopes)helps with authorization scenarios.- Use the shared Testing package for fixtures and assertions.
When to use it
Use this package for API tests that need to exercise routing, middleware, authentication and response serialization through the toolkit’s native ASP.NET Core and Lambda hosting paths. It complements unit tests; external dependencies still need appropriate test implementations or isolated infrastructure.
How to use it
- Derive a test class from
RestApiTestCaseBase<TStartup, TAppSettings>, supplying aWebApplicationFactory<TStartup>, aTestableLambdaEntrypoint<TStartup>and the application’s authorization scopes. The settings type must implementIAuthServiceAppSettings. - Build requests with
Get,Post,PutorPatch, and assert status and parsed output with the endpoint test methods. Configure embedded test settings and the mock token issuer for authenticated scenarios. - Use
TestEndpointAsyncwhen native and Lambda responses should be deterministic and equal. For timestamps, generated IDs or other variable output, callTestEndpointNativeAsyncandTestEndpointLambdaAsyncseparately and assert the relevant behavior in each.
The runnable greeting API test shows the fixture constructor and a request assertion.
See the sample tests, testing conventions and toolkit overview.
Releases
See the release notes for the complete release history.