Skip to main content

Score a test run

Stepscorecontrol

Checks what a test run made against what its test case expects, and gives each check a pass or a fail with the reason.

At a glance​

PropertyValue
Step namescore
ResourceClusterStep (lumen.ai/v1alpha1)
Palette group, categorycontrol, logic
Credits0 credits each time it succeeds
Side effectsno
Installation must providenothing

Inputs​

PropertyValue
Needsnothing
Producesfields
Works onitem one document at a time

Needs and Produces are data types (file, text, fields, email). The editor offers a step only where what it needs is already on the path. See Documents and data.

Outputs​

A later node references an output as {nodeId.field} in text, or nodeId.field in a condition.

OutputType
passedboolean
scorenumber
checksarray
failednumber

Settings​

Set under config: on the flow node. Text settings may contain {nodeId.field} placeholders.

SettingTypeDefaultDescription
checksrequiredlist of object-ChecksminItems 1; maxItems 50
checks[].namerequiredstring-Name is the metric, as results show it.minLength 1; maxLength 63
checks[].actualrequiredstring-Actual is the field checked, as a condition names it: <node>.<field>, walking into a JSON answer (extract.reply.source). It is read from that node's own output.minLength 1; maxLength 200
checks[].oprequiredstring-Op is how: equals, contains, matches (a regular expression), json (the expected JSON is part of the value), changes (a change list against the expected list), count (a list's length or a number), exists.one of equals, contains, matches, json, changes, count, exists
checks[].expectedstring-Expected is the value to check against, written here.maxLength 4000
checks[].expectedColumnstring-ExpectedColumn takes the expected value from the test case's column instead (run.case.<column>).maxLength 63
checks[].modestring"equal"Mode is a changes check's: equal (exactly these changes, a change not expected is a wrong write and fails) or include (at least these).one of equal, include
minScorenumber-MinScore is the share of checks that must pass for the run to pass, from 0 to 1. Unset is 1: every check.minimum 0; maximum 1

The full JSON Schema of these settings: score.schema.json.

Example​

Check the total

config
checks:
- actual: read.total
expected: "1170"
name: total
op: equals

Use it in a flow​

A node that runs score goes under spec.nodes of a Flow. Give it any id, and list the next node ids in next.

flow.yaml
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: score-example
namespace: tenant-acme
spec:
displayName: "Score a test run"
triggers:
- id: start
ref: {name: manual-run}
next: [score]
nodes:
- id: score
stepRef: {name: score}
config:
checks:
- actual: read.total
expected: "1170"
name: total
op: equals