# Test Summary & Quality Gate Report

Reads the test results for one change against the plan they were run for and the rules the release is gated on, and reports what was actually established, what was not, and what those rules therefore allow.

## Deliverable

One Markdown document, `quality-gate-report.md`, in the structure set out under **Output** below. It closes the loop that **Test Strategy Definition** opens: it reads results against that strategy, takes its defects from **Defect Triage & Prioritisation** as triaged, and hands its outcome to **Release Readiness & Rollback**.

## Required inputs

- **The results** — one record per test run: the test, its outcome, the environment and the identifier of the build it ran against.
- **The plan they were run against** — the test strategy or test plan: what was intended to run, at which level and in which environment.
- **The gate's rules** — what blocks a release, as the owner of the gate defined them, including who may grant a waiver.
- **The open defects** — each with the severity it was triaged at and its status.

If the results, the plan or the gate's rules are absent, stop and report it. If the defects are not supplied, continue, record them as `unknown`, and state that no outcome other than `block` can be reached without them.

## Optional inputs

- The change set the tests were meant to cover
- Earlier runs of the same tests, to show which results are unstable
- Coverage data, and how it was measured
- A list of issues already known and accepted, with who accepted them
- Waivers already granted, with their owners and their conditions

Absent optional inputs do not stop the report. Each becomes a line saying what could not be checked and who holds the material that would check it.

## Execution

**1 — Attribute every result to a build and an environment.** Results that cannot be tied to the build under gate are listed as `unattributed` and excluded from every count that follows. A result is evidence about the build it ran against, and no other.

**2 — Reconcile what was run with what was planned.** For each planned item: `passed`, `failed`, `blocked` or `not run`. List runs that were not in the plan separately and say so; they do not count towards the plan.

**3 — Account for every failure.** Each one is a product defect, a defect in the test, a fault of the environment or `unexplained`, with the evidence for the classification and a link to the defect where there is one. A failure is never reclassified to make a number look better, and an `unexplained` failure counts as a failure.

**4 — Account for everything skipped or not run.** The reason, who decided it, and what it leaves untested.

**5 — Bring in the open defects as triaged.** Severity, status and owner as supplied. The report does not re-triage; where a severity looks wrong, it raises the question and leaves the value alone.

**6 — Apply each of the gate's rules exactly as written.** For every rule: `met`, `not met` or `cannot be evaluated`, with the records that decide it. A rule that cannot be evaluated because evidence is missing is not treated as met.

**7 — State the residual risk.** What the change touches that no executed test covers, taken from the change set where supplied and from the plan otherwise. Where neither exists, record `unknown` rather than estimating.

**8 — Derive the outcome from the rules.** `pass` when every rule is met. `block` when any rule that blocks is not met or cannot be evaluated. `conditional` only where the gate's own rules allow a waiver, and then with each condition, its owner and who granted it. The outcome is a consequence of the rules, not of how the results feel.

**9 — Leave the sign-off to people.** The report names who must accept the outcome and records that it has not been signed. It does not sign on anyone's behalf.

## Output

`quality-gate-report.md`, in this order:

- **1. Build and environments** — what the results belong to, and what is `unattributed`
- **2. Plan against execution** — per planned item: passed, failed, blocked or not run
- **3. Failures** — each one classified, with evidence and defect link
- **4. Not run and skipped** — reason, decider and what remains untested
- **5. Open defects** — as triaged, with status and owner
- **6. Gate rules** — each rule: met, not met or cannot be evaluated, with the deciding records
- **7. Residual risk** — changed areas no executed test covers
- **8. Outcome** — pass, conditional or block, and the rules that produced it
- **9. Conditions and sign-off** — each condition with its owner, and who must accept the outcome
- **10. What could not be checked** — missing inputs and who holds them

## Validation

The report is ready when all of these hold:

- Every result in the input appears in section 1 attributed, or as `unattributed`
- Every planned item appears in section 2 with one of the four states
- Every failure in section 3 is classified and carries evidence, and none is reclassified to a pass
- Every gate rule has a line in section 6, and none is `met` without a deciding record
- The outcome in section 8 follows from section 6 alone
- No count, rate or coverage figure appears that no input supplied

Fail the run if the outcome is stronger than the rules allow, or if a failure is hidden by reclassification.

## Failure handling

- **No gate rules supplied** — stop. Report that an outcome cannot be derived from rules nobody has stated, and name **Test Strategy Definition**, which records what the pipeline blocks on.
- **Results not tied to a build** — list every one as `unattributed`, reach no outcome other than `block`, and state that the results must be re-run or re-labelled by whoever holds the build identifiers.
- **Open defects missing** — mark section 5 `unknown`, evaluate every rule that does not depend on them, and mark the rest `cannot be evaluated`.
- **The plan is missing or has drifted from what was run** — report execution against what was run, state that the plan cannot vouch for it, and list the plan items that have no result.
- **Partial material** — report what the material supports, mark the rest `NOT EVALUATED — pending <material>`, and deliver.
