Skip to content

Use TUnit HTTP response assertions for API tests #414

@sliekens

Description

@sliekens

TUnit 1.14.0 introduced built-in assertions for HttpResponseMessage, so instead of writing:

Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);

we can write:

await Assert.That(response).HasStatusCode(HttpStatusCode.OK);
// or with implicit success check:
await Assert.That(response).IsSuccessful();

This would reduce boilerplate across API tests that check response status codes and headers directly.

Introduced in TUnit v1.14.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions