AI Test Report: Build an Evidence-Based Run Summary

A QA lead should not have to read logs to understand a run. A useful AI test report answers a few plain questions: What did we test? What passed and failed? What evidence do we have? What needs a person’s decision? You will build one from data that the workflow has already recorded.

📖 What You’ll Learn

  • What a QA lead needs from a report
  • Why a report should not be written by a model
  • How to report stopped runs honestly
  • How to keep secrets out of reports

💡 What Belongs in an AI Test Report

Explain Like I’m 5: A School Report

Imagine: It says what you studied, how you did and what you need to work on. It does not say only “Good”.

What it really means: A report gives facts, evidence and next steps.

In testing: It lists what passed, what failed and what is undecided.

SectionQuestion it answers
Run detailsWhen, where and with which model?
TraceabilityWhich scenario covers which requirement?
ResultsWhat passed, failed or was skipped?
Failure analysisWhy did it fail, and how sure are we?
ChangesWhat did the AI change?
ApprovalsWho agreed to what?
Open questionsWhat still needs a decision?

You wrote this kind of summary by hand in Test Summary Report with AI.


🔍 Numbers Must Come from the Run

Explain Like I’m 5: Counting the Sweets

Imagine: You count the sweets in the jar. You do not ask someone to guess how many there are.

What it really means: Results are counted by code, and never written by a model.

In testing: The pass count comes directly from Playwright’s report.

This reporter uses no model at all. A model could summarise for readers later, but the record of what happened must be exact.

Replace src/agents/reporter.agent.ts.

import { mkdir, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import type { Agent } from '../core/agent.js';
import { redact } from '../core/guardrails.js';
import type { WorkflowState } from '../core/workflow-state.js';

export function buildMarkdown(state: WorkflowState): string {
  const traceability = (state.plan?.scenarios ?? []).map(
    (item) => `| ${item.id} | ${item.title} | ${item.requirementIds.join(', ')} |`,
  );
  const failures = state.analyses.map(
    (item) => `- **${item.testTitle}:** ${item.category} (${item.confidence}). ${item.summary}`,
  );
  const approvals = state.approvals.map(
    (item) => `- ${item.action}: ${item.approved ? 'approved' : 'rejected'} at ${item.decidedAt}`,
  );

  return redact(
    [
      `# QA Agent Run ${state.runId}`,
      `Status: ${state.status}${state.stopReason ? ` (${state.stopReason})` : ''}`,
      `Model provider: ${state.llmProvider}`,
      '## Traceability',
      ['| Scenario | Title | Requirements |', '|---|---|---|', ...traceability].join('\n'),
      '## Results',
      ...[['First run', state.firstRun], ['After healing', state.finalRun]].flatMap(([label, item]) =>
        item && typeof item !== 'string'
          ? [`${label}: passed ${item.passed}, failed ${item.failed}, skipped ${item.skipped}`]
          : [],
      ),
      ...(state.firstRun ? [] : ['Tests were not executed.']),
      '## Failure Analysis',
      ...(failures.length > 0 ? failures : ['No failures were analysed.']),
      '## Changes',
      state.healing
        ? `${state.healing.explanation} Applied: ${state.healing.applied}`
        : 'No patch was proposed.',
      '## Approvals',
      ...(approvals.length > 0 ? approvals : ['No approvals were recorded.']),
      '## Open Questions',
      ...(state.parsed?.ambiguities ?? ['None recorded.']),
    ].join('\n\n'),
  );
}

const escapeHtml = (text: string) =>
  text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

export class ReporterAgent implements Agent<WorkflowState, string> {
  readonly name = 'reporter';

  constructor(private readonly root: string) {}

  async run(state: WorkflowState): Promise<string> {
    const folder = resolve(this.root, 'reports');
    await mkdir(folder, { recursive: true });
    const markdown = buildMarkdown(state);
    await writeFile(resolve(folder, `${state.runId}.md`), markdown, 'utf8');
    await writeFile(
      resolve(folder, `${state.runId}.html`),
      `<!doctype html><meta charset="utf-8"><pre>${escapeHtml(markdown)}</pre>`,
      'utf8',
    );
    await writeFile(
      resolve(folder, `${state.runId}.json`),
      redact(JSON.stringify(state, null, 2)),
      'utf8',
    );
    return `reports/${state.runId}.md`;
  }
}

Notice that the report shows both the first run and the run after healing. Showing only the final green result would hide that the tests failed.


🧩 Test the Reporter

Create tests/unit/reporter.test.ts.

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { buildMarkdown } from '../../src/agents/reporter.agent.js';
import { createState } from '../../src/core/workflow-state.js';

test('a stopped run says that tests were not executed', () => {
  const state = createState('run-1', 'text', 'mock');
  state.status = 'stopped';
  state.stopReason = 'A person rejected writing the generated code';
  const report = buildMarkdown(state);
  assert.match(report, /Status: stopped/);
  assert.match(report, /Tests were not executed/);
});

test('reports never include secrets', () => {
  const state = createState('run-2', 'text', 'mock');
  state.status = 'stopped';
  state.stopReason = 'password=hunter2 failed';
  assert.doesNotMatch(buildMarkdown(state), /hunter2/);
});

Report the runs that did not finish

“Tests were not executed” is an important result. A report that looks fine when nothing ran is worse than no report at all.


🛠️ See a Real Report

Run the failure demo again, and approve each step.

npm run agent -- requirements/login.md --demo-failure

Open the newest file in reports/. Here is part of the output from a real run.

## Results

First run: passed 0, failed 3, skipped 0

After healing: passed 3, failed 0, skipped 0

## Changes

The explorer observed the login form at /login, not /signin. Applied: true

## Approvals

- write-generated-code: approved at 2026-11-10T09:09:51.305Z
- run-generated-tests: approved at 2026-11-10T09:09:55.413Z
- apply-healing-patch: approved at 2026-11-10T09:11:29.886Z

## Open Questions

The requirement does not say how many failed attempts are allowed

📌 Make the Report Useful to Readers

Explain Like I’m 5: A Note on the Fridge

Imagine: “Milk is finished. Please buy some.” Everyone in the house knows what to do.

What it really means: A good report ends with what someone needs to do.

In testing: Open questions are listed where a lead will see them.

You can add a short plain-language summary at the top. If you use a model for it, give it only the data in the report, and keep the exact numbers below it. Your Playwright reporters knowledge helps you link the HTML report and traces.


🌍 Real-Life Example: The Green Dashboard

A dashboard shows zero failures because a job crashed before it ran any tests. Leadership assumes that all is well for a week. A report that says “Tests were not executed” would have raised the alarm on the first day.


🧪 Try It Yourself

  1. Replace the reporter and run the unit tests.
  2. Run the demo and open the Markdown and HTML reports.
  3. Reject an approval, and read the stopped report.
  4. Add a section showing how long the run took.
  5. Read the JSON report, and check that it has no secrets.

📋 Ready-to-Copy Prompt

You are a QA lead reviewing an automated test report.

Report:
[paste the report with no secrets]

Tell me:
1. What I can trust, and what I cannot
2. What decisions I need to make
3. What information is missing
4. How to make it clearer for a non-technical manager

Do not change or invent any numbers.

⚠️ Common Mistakes

  • Letting a model write the pass and fail counts
  • Showing only the final result after healing
  • Giving no report when a run stops early
  • Leaving secrets in logs and reports
  • Hiding open questions at the end of a long log

🎯 Key Takeaways

  • Reports must answer a reader’s real questions.
  • Exact results come from data, not from a model.
  • A stopped run needs a clear report too.
  • Show the whole story, including AI changes.

🎤 Interview Questions

1. What makes a good test report?

Model answer: It states what was tested, the results with evidence, any changes and approvals, and what needs a decision. A reader should not need to look at raw logs.

2. Would you let an LLM write the test report?

Model answer: It can write a summary, but counts and outcomes should come directly from the run data. Numbers must be exact and traceable.

3. How do you report on healed tests?

Model answer: I show both the original failures and the results after healing, plus the patch and who approved it. Otherwise, the report would hide what really happened.

4. How do you keep secrets out of reports?

Model answer: I avoid collecting them and run redaction before writing any report. I also test this and review artifacts such as traces.

5. Why report a run that did not execute?

Model answer: A missing result can look like a pass. Stating that tests were not executed, and why, prevents false confidence.


📝 Assignment

Add links to the trace and screenshot paths for each failed test. Then show the report to a colleague, and ask them what they would do next. Improve one section based on their answer.


❓ FAQ

Do I need all three report formats?

Markdown is easy to read, HTML is easy to share and JSON is easy for tools to process. Keep whichever your team uses.

Is redaction enough to make reports safe?

No. Traces and screenshots can also contain sensitive data, so use synthetic data and restrict who can see them.


🚀 Next Steps

Well done on finishing this lesson. Complete the assignment, then continue with MCP Browser Tool: Connect Your QA Agent, Read-Only First.