N NezamDocumentation

Test grammar#

Test grammar describes test declarations, fixtures, setup blocks, assertions, and expected error paths.

Source#

PropertyValue
Grammar filepackages/business/language/grammar/test.g4
Grammar nametest
Grammar kindparser
Importscommon, type, expression
Imported byBusinessLanguage, module
Direct rule or token count8

How to use this page#

Read the examples first when authoring Business Language. Use the rule inventory when checking exact grammar coverage or when updating parser, lowering, editor, or documentation behavior.

Entry rules and syntax families#

Start with these rules when reading this grammar: testDeclaration.

  • Declarations: testDeclaration

Key grammar excerpts#

testDeclaration#

antlr
testDeclaration: TEST identifier OPEN_BRACE testMemberList? CLOSE_BRACE;

Complete rule and token inventory#

text
testAssertion, testContext, testDeclaration, testExpectation, testMatcher, testMember, testMemberList, testSetup

Examples#

Success assertion#

bl
test vendor_lookup_returns_vendor {
  context vendor_id: VendorId = "V-100";
  setup {
    seed_vendor(vendor_id);
  }
  assert find_vendor(vendor_id) != null;
  teardown {
    clear_vendor(vendor_id);
  }
}

Failure expectation#

bl
test missing_approval_policy_fails_closed {
  context invoice_id: InvoiceId = "INV-100";
  expect post_invoice(invoice_id) to throw MissingApprovalPolicy;
}

Comparison matchers#

bl
test matcher_examples {
  context invoice: Invoice = sample_invoice;

  expect calculate_total(invoice) to equal invoice.amount;
  expect invoice.tags to contain expected_tag;
  expect invoice.status to be expected_status;
}

Common authoring mistakes#

  • Do not copy examples without checking the rule inventory for the exact grammar boundary.
  • Do not add behavior that depends on missing configuration or undeclared user-facing errors.
  • /language/testing/
  • /language/rules-tests-errors/

Authoring notes#

  • Keep examples aligned with the grammar source, not with inferred syntax from another language.
  • Use declared messages for user-facing failures, and fail closed when required configuration is absent.
Source: packages/business/language/grammar-files/test.md