09. Testing with @test (Hypervisor)

@test is required for Hypervisor profile conformance.

Minimal syntax

@test "basic"
  vars:
    username: "TestUser"
  input:
    query: "hello"
  mock:
    WeatherAPI.get_current: { temp: 10, condition: "Rain" }
  assert:
    - canonical.messages[0].role == "system"
    - canonical contains "hello"
    - telemetry.gas_used < 5000

Semantics

Example file

@vars
  query: @input(type="string")

@system
  content: "You are helpful."

@user
  content: $query

@test "query-roundtrip"
  input:
    query: "hello"
  assert:
    - canonical.messages[1].role == "user"
    - canonical contains "hello"

Run:

facet-fct test --input test_example.facet

Pure mode expectations

In pure mode tests:

Practical tips