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.
  • TestableLambdaEntrypoint supports 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

  1. Derive a test class from RestApiTestCaseBase<TStartup, TAppSettings>, supplying a WebApplicationFactory<TStartup>, a TestableLambdaEntrypoint<TStartup> and the application’s authorization scopes. The settings type must implement IAuthServiceAppSettings.
  2. Build requests with Get, Post, Put or Patch, and assert status and parsed output with the endpoint test methods. Configure embedded test settings and the mock token issuer for authenticated scenarios.
  3. Use TestEndpointAsync when native and Lambda responses should be deterministic and equal. For timestamps, generated IDs or other variable output, call TestEndpointNativeAsync and TestEndpointLambdaAsync separately 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.