# Score a test run

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

Source: https://docs.go-lumen.ai/reference/steps/score

## At a glance

| Property | Value |
| --- | --- |
| **Step name** | `score` |
| **Resource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palette group, category** | control, logic |
| **Credits** | **0** credits each time it succeeds |
| **Side effects** | no |
| **Installation must provide** | nothing |

## Inputs

| Property | Value |
| --- | --- |
| **Needs** | nothing |
| **Produces** | `fields` |
| **Works on** | item: 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](https://docs.go-lumen.ai/concepts/how-flows-run.md#documents-and-data).

## Outputs

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

| Output | Type |
| --- | --- |
| `passed` | boolean |
| `score` | number |
| `checks` | array |
| `failed` | number |

## Settings

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

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `checks` (required) | list of object |  | Checks (minItems 1; maxItems 50) |
| `checks[].name` (required) | string |  | Name is the metric, as results show it. (minLength 1; maxLength 63) |
| `checks[].actual` (required) | string |  | 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[].op` (required) | string |  | 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[].expected` | string |  | Expected is the value to check against, written here. (maxLength 4000) |
| `checks[].expectedColumn` | string |  | ExpectedColumn takes the expected value from the test case's column instead (run.case.<column>). (maxLength 63) |
| `checks[].mode` | string | `"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) |
| `minScore` | number |  | 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](https://docs.go-lumen.ai/schemas/steps/score.schema.json).

## Example

Check the total

```yaml title="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](https://docs.go-lumen.ai/concepts/how-flows-run.md#the-flow-as-yaml). Give it any id, and list the next node ids in next.

```yaml title="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
```
