Skip to content

Contract-driven testing: vera test command #79

@aallan

Description

@aallan

Summary

Vera's contracts already define what each function requires and guarantees. The three-tier verification system already classifies which properties are proved (Tier 1) vs runtime-checked (Tier 3). A vera test command would close the loop by automatically exercising Tier 3 contracts with generated inputs.

Motivation

In traditional development, tests are a separate artefact maintained alongside code. In Vera, contracts ARE the specification — requires() defines the valid input space, ensures() defines expected behavior. Test management should fall out of the language design, not be bolted on.

What this enables

  • Property-based test generationrequires() clauses define the input space; the compiler generates valid inputs automatically and checks ensures() at runtime
  • Automatic coverage reportingvera verify already reports Tier 1 (proved) vs Tier 3 (runtime) counts; vera test would exercise the Tier 3 contracts
  • No separate test files for contract-covered properties — the contracts are the tests

Possible future extensions

  • Cross-function scenario testing (call A then B then C, check end-to-end properties)
  • Mutation testing (change the implementation, see if any contract breaks)
  • Shrinking (minimize failing inputs, as in QuickCheck/Hypothesis)

Relationship to existing work

  • Contracts and verification are complete (C4/C6)
  • Runtime contract insertion is working (Tier 3 checks compile to WASM)
  • vera verify --json already provides the tier breakdown (tier1_verified, tier3_runtime, total)

Roadmap

Fits naturally into C8 (end-to-end) or as a standalone phase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C8bC8b — Diagnostics and toolingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions