Skip to content

Guardrails / Collectors

Test results ​

The test results the build already wrote, read from whichever report format it left behind and normalized into one shape: the totals across every report, and the cases that failed, errored or were skipped. Passing cases are left out, because guardrails gate on the others and Buildnote already records every case as a test event. Nothing identifies a case across reports, so when a build writes both a report per class and a merged report, every case is counted in both.

Facts keytests
Versionv1
Scripttests.py
Timeout60 seconds

Inputs ​

InputDescriptionDefaultEnvironment
reportsComma separated globs matched against every file in the working directory and against bare file names, naming the test reports to read.TEST-*.xml,*-test-report.xml,junit*.xml,test-results*.xml,*.trx,*-ctrf.json,open-test-report.xmlGUARDRAIL_INPUT_REPORTS
maxFailuresMaximum number of cases to carry in failures and in skipped, each counted separately. The totals still include cases that are dropped.50GUARDRAIL_INPUT_MAXFAILURES

When a guardrail declares an input with the same name, it passes its value through. That means you set these values in the guardrail's configuration in buildnote.json.

A guardrail asks for these facts by name and reads them back by the same name:

json
{
  "collect": ["tests"]
}
python
tests = guardrail.facts("tests")

Facts ​

These are the fields of the document tests collects. In a path, [] means each entry of the list before it, and [path] means a key of the object before it.

FactMeaning
sourcereport when a test report was read, none when there was none.
reasonWhy nothing was read, present only when source is none.
reportsEvery report that was read, in path order.
reports[].pathPath of the report, relative to the directory the CLI runs in.
reports[].modifiedWhen the report was last written, in ISO 8601, so you can spot a stale report.
reports[].formatFormat it was read as: junit, nunit, trx, otr or ctrf.
totals.testsCases across every report that was read, summed rather than deduplicated.
totals.passedCases that passed.
totals.failedCases that failed an assertion.
totals.errorsCases that ended in an error rather than a failed assertion.
totals.skippedCases that were skipped, ignored or left inconclusive.
totals.durationMsHow long the reports say the cases took, summed, or null when no report stated a duration.
suitesHow many report files contributed to the totals.
failuresThe failed and errored cases, up to maxFailures.
failures[].nameName of the case, as the report gave it.
failures[].classnameClass or suite the case belongs to, or null when the report names none.
failures[].statusfailed for a failed assertion, error for a case that ended in an error.
failures[].fileFile the case was declared in, or null when the report names none.
skippedThe skipped cases, up to maxFailures.
skipped[].nameName of the case, as the report gave it.
skipped[].classnameClass or suite the case belongs to, or null when the report names none.
skipped[].statusAlways skipped.
skipped[].fileFile the case was declared in, or null when the report names none.
droppedCases left out of failures and skipped because maxFailures was reached.

If a collector can't finish, it prints what it gathered so far along with an incomplete key that says why. Facts after the point where it stopped are missing, so a check that depends on them should read incomplete first.

Example facts ​

Here are the facts the tests collector gathers from an example project:

json
{
  "source": "report",
  "reports": [
    {
      "path": "TEST-com.company.widget.QueueTest.xml",
      "modified": "2026-03-04T10:15:00Z",
      "format": "junit"
    }
  ],
  "totals": {
    "tests": 4,
    "passed": 2,
    "failed": 1,
    "errors": 0,
    "skipped": 1,
    "durationMs": 624
  },
  "suites": 1,
  "failures": [
    {
      "name": "rejects a negative limit",
      "classname": "com.company.widget.QueueTest",
      "status": "failed",
      "file": "service/src/test/kotlin/QueueTest.kt"
    }
  ],
  "skipped": [
    {
      "name": "drops the oldest under load",
      "classname": "com.company.widget.QueueTest",
      "status": "skipped",
      "file": "service/src/test/kotlin/QueueTest.kt"
    }
  ],
  "dropped": 0
}

Collected for ​

GuardrailCategoryInputs
tests/no-failurestestsnone
tests/no-skipped-growthtestsnone
tests/results-publishedtestsnone

All collectors

Buildnote Limited
Registered in England and Wales, Reg: 16140412