{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openlineage.io/spec/facets/1-0-1/TestRunFacet.json",
  "$defs": {
    "TestRunFacet": {
      "description": "Results of test executions associated with this run, capturing test outcomes and configured severities independently of dataset attribution.",
      "allOf": [
        {
          "$ref": "https://openlineage.io/spec/2-0-2/OpenLineage.json#/$defs/RunFacet"
        },
        {
          "type": "object",
          "properties": {
            "tests": {
              "description": "List of test executions and their results.",
              "type": "array",
              "items": {
                "$ref": "#/$defs/TestExecution"
              }
            }
          },
          "required": ["tests"]
        }
      ],
      "type": "object"
    },
    "TestExecution": {
      "type": "object",
      "description": "A single test execution and its result.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name identifying the test.",
          "example": "assert_no_orphans"
        },
        "status": {
          "type": "string",
          "description": "Whether the test found issues: 'pass' (no issues found), 'fail' (issues found), 'skip' (not executed). Independent of severity — a test can fail without blocking the pipeline when severity is 'warn'.",
          "example": "pass"
        },
        "severity": {
          "type": "string",
          "description": "The configured consequence of a test failure: 'error' (blocks pipeline execution) or 'warn' (produces a warning only, does not block). A test with severity 'warn' and status 'fail' means issues were found but execution continued.",
          "example": "error"
        },
        "type": {
          "type": "string",
          "description": "Classification of the test, e.g. 'not_null', 'unique', 'row_count', 'freshness', 'custom_sql'.",
          "example": "not_null"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description of what the test checks.",
          "example": "Ensures all order IDs are unique across the table."
        },
        "expected": {
          "type": "string",
          "description": "The expected value or threshold for the test, serialized as a string.",
          "example": "1000"
        },
        "actual": {
          "type": "string",
          "description": "The actual value observed during the test, serialized as a string.",
          "example": "999"
        },
        "content": {
          "type": "string",
          "description": "The test body, e.g. a SQL query or expression.",
          "example": "SELECT COUNT(*) FROM orders WHERE amount < 0"
        },
        "contentType": {
          "type": "string",
          "description": "The format of the content field, allowing consumers to interpret or filter test content. Common values include 'sql', 'json', 'expression'.",
          "example": "sql"
        },
        "params": {
          "type": "object",
          "description": "Arbitrary key-value pairs for check-specific inputs.",
          "additionalProperties": true
        }
      },
      "required": ["name", "status"]
    }
  },
  "type": "object",
  "properties": {
    "test": {
      "$ref": "#/$defs/TestRunFacet"
    }
  }
}
