# 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/de/reference/steps/score

## Auf einen Blick

| Eigenschaft | Wert |
| --- | --- |
| **Schrittname** | `score` |
| **Ressource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palettengruppe, Kategorie** | control, logic |
| **Credits** | **0** Credits bei jedem Erfolg |
| **Externe Wirkung** | nein |
| **Die Installation muss bereitstellen** | nichts |

## Eingaben

| Eigenschaft | Wert |
| --- | --- |
| **Braucht** | nichts |
| **Liefert** | `fields` |
| **Arbeitet auf** | item: einem Dokument nach dem anderen |

Braucht und Liefert sind Datentypen (file, text, fields, email). Der Editor bietet einen Schritt nur dort an, wo das, was er braucht, schon auf dem Pfad liegt. Siehe [Dokumente und Daten](https://docs.go-lumen.ai/de/concepts/how-flows-run.md#documents-and-data).

## Ausgaben

Ein späterer Knoten verweist auf eine Ausgabe als `{nodeId.field}` in einem Text oder als `nodeId.field` in einer Bedingung.

| Ausgabe | Typ |
| --- | --- |
| `passed` | boolean |
| `score` | number |
| `checks` | array |
| `failed` | number |

## Einstellungen

Wird unter `config:` im Knoten des Flows gesetzt. Texteinstellungen dürfen Platzhalter wie `{nodeId.field}` enthalten.

| Einstellung | Typ | Standardwert | Beschreibung |
| --- | --- | --- | --- |
| `checks` (erforderlich) | list of object |  | Checks (minItems 1; maxItems 50) |
| `checks[].name` (erforderlich) | string |  | Name is the metric, as results show it. (minLength 1; maxLength 63) |
| `checks[].actual` (erforderlich) | 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` (erforderlich) | 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) |

Das vollständige JSON Schema dieser Einstellungen: [score.schema.json](https://docs.go-lumen.ai/schemas/steps/score.schema.json).

## Beispiel

```yaml title="config"
checks:
- actual: read.total
  expected: "1170"
  name: total
  op: equals
```

## Im Flow verwenden

Ein Knoten, der `score` ausführt, steht unter `spec.nodes` eines [Flow](https://docs.go-lumen.ai/de/concepts/how-flows-run.md#the-flow-as-yaml). Geben Sie ihm eine beliebige id und nennen Sie in next die ids der nächsten Knoten.

```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
```
