AxiomCore
Workflows

Testing contracts

Define request checks, lifecycle hooks, captures, and assertions in Acore.

The native test runner executes TestConfig suites against each suite's configured base URL. It is a live HTTP/WebSocket test path, not a static source assertion.

Minimal suite

testConfig = TestConfig {
  defaults = TestDefaults { timeoutMs = 5000 }
  suites = [
    TestSuite {
      name = "Task API"
      baseUrl = "http://localhost:8080"
      tags = ["smoke"]
      checks = [
        CheckDef {
          label = "List tasks"
          route = Routes.list_tasks
          expect = [
            StatusExpectation { value = 200 }
            DurationExpectation { op = "lt" valueMs = 500 }
            HeaderExpectation {
              key = "content-type"
              op = "contains"
              value = "application/json"
            }
          ]
        }
      ]
    }
  ]
}
axiom test axiom.acore
axiom test axiom.acore --tag smoke

Requests and expectations

CheckDef selects either a declared route or an explicit url and can provide path/query parameters, body, and headers. It also controls retry, timeout, skipping, captures, and continuation behavior.

Implemented expectation families cover:

  • status and duration;
  • response schema;
  • body path comparisons and every/some/none quantifiers;
  • headers; and
  • named groups of expectations.

Capture values

capture = [
  ResponseCapture { path = "token" bindAs = "sessionToken" type = "string" }
]

Captured values are scoped test data for later checks/hooks. Do not print or commit real production tokens.

Lifecycle and isolation

Suites can declare typed lifecycle hooks. Use them to create/reset fixtures and make state ownership explicit. Prefer a dedicated test or local mock base URL; an explicit URL can perform real writes.

Run contract tests alongside, not instead of, the backend's unit/integration tests and the consuming application's tests.

On this page