Skip to main content
The test block defines an automated test that instantiates a module under test and asserts on the resulting values. Tests are run by ubx test and conventionally live in *.test.xcl files.

Syntax

test name {
  binding = module "modname" {
    source = "./path/to/module"
    // input values
  }

  assert {
    condition     = <boolean expression>
    error_message = <string expression>
  }
}
The label is a bare identifier, quotes optional. A quoted label may contain spaces.

Fields

FieldDescription
<binding> = module "…" { }Instantiates a module under test. The source field is required; every other field is passed to the module as an input. The binding name exposes the module’s outputs.
assert { }An assertion block. One or more may appear. See assert.

Assert blocks

Each assert block has exactly two required fields:
FieldDescription
conditionA boolean expression that must evaluate to true for the test to pass.
error_messageA string expression reported when the condition is false.
All assert blocks in a test are evaluated and every failure is reported — the runner does not stop at the first failure.

Example

test vpc_defaults {
  net = module "networking" {
    source   = "./modules/networking"
    vpc_cidr = "10.0.0.0/16"
  }

  assert {
    condition     = net.vpc_cidr == "10.0.0.0/16"
    error_message = "VPC CIDR should match the input"
  }
}

Running tests

Run all tests in a directory with ubx test. Each test block instantiates its module, evaluates every assert, and reports any failures.