Skip to main content

Test Assertion Patterns

Overview

This page defines assertion standards for Bruno API tests. The goal is to eliminate false-pass tests, add meaningful response validation, and keep error-path behavior explicit.

False-Pass Patterns

Skip on Non-200

Do not guard all assertions behind a success status. Always assert the expected status directly.

Overly Broad Status Checks

Avoid accepting broad ranges or mixed success/error status lists for a happy path. Assert the exact expected code.

No Body Validation

Every happy-path request should assert both the status code and at least one meaningful response property.

Wrong Expected Code

Match the endpoint contract. Creation endpoints may return 201; validation failures may return 400 or 422.

Minimum Assertion Standard

Every request should include:

  • exact status assertion
  • JSON/content-type assertion when the endpoint returns JSON
  • response-shape assertion for happy paths
  • error-code or message assertion for error paths

Gap Categories

CategoryPriorityDescription
FALSE_PASSCriticalTest accepts a failure as success
WRONG_STATUS_CODECriticalTest checks the wrong specific code
NO_ERROR_SCENARIOSHighEndpoint lacks invalid-input coverage
NO_TESTSHighRequest has no assertions
HAPPY_PATH_ONLYMediumOnly checks success status
NO_BODY_VALIDATIONMediumChecks status but not response shape
NO_CONTENT_TYPELowMissing content-type assertion

Editing Rules

  • Keep request files valid .bru syntax.
  • Preserve existing passing coverage unless the endpoint contract changed.
  • Prefer focused request files over large multi-purpose scripts.
  • Run the smallest relevant Bruno folder after edits.