Automated Test Report Generation: A Practical Automotive Engineering Guide

Automated test reports convert execution data into reviewable engineering evidence. In automotive ECU testing, a useful report should explain what was tested, against which requirement, on which ECU/software baseline, under what bench conditions, and why a test passed or failed.

A robust design separates test execution, structured result storage, report generation and artifact retention. This makes the report reproducible and allows the same results to be rendered as HTML, PDF or a dashboard without rerunning the ECU test.

1. Report-generation architecture

Rendering diagram...

Keep the original execution results as the source of truth. The report is a view of those results, not a replacement for them.

ComponentResponsibility
Test runnerExecutes test cases and records observations
Result modelStores test identity, metadata, measurements and verdict
ValidatorChecks required fields, data types and allowed verdicts
AggregatorCalculates totals and summarizes outcomes
RendererProduces HTML or another presentation format
Artifact storeRetains BLF, log, screenshot and other evidence files

2. Define a stable result schema

Agree on a result structure before writing templates. A practical record can include:

FieldPurpose
run_idIdentifies one complete test execution
test_idUnique test-case identifier within the test catalog
requirement_idRequirement verified by the test
statusPASS, FAIL, INCONCLUSIVE, SKIPPED or ERROR
started_at, ended_atTime-stamped execution boundaries with timezone
ecu_swECU software/build identification
bench_idTest bench or setup identification
measurementsObserved values, units and limits
artifactsRelative paths to trace files and logs
failure_reasonExplanation when the test does not pass

Use a schema version so that future changes to the result format can be handled explicitly. Do not silently reinterpret old result files after changing field names or verdict rules.

3. Example structured test result

The following JSON record is illustrative:

{
  "schema_version": "1.0",
  "run_id": "RUN_2026_001",
  "test_id": "NET_001",
  "requirement_id": "REQ-COM-012",
  "status": "PASS",
  "started_at": "2026-11-28T09:00:00+05:30",
  "ended_at": "2026-11-28T09:00:04+05:30",
  "ecu_sw": "example-build-id",
  "bench_id": "HIL_BENCH_01",
  "measurements": [
    {
      "name": "message_inter_arrival",
      "observed": 99.8,
      "unit": "ms",
      "limit_min": 90.0,
      "limit_max": 110.0
    }
  ],
  "artifacts": [
    "artifacts/RUN_2026_001/NET_001.blf"
  ],
  "failure_reason": null
}

The example values are not acceptance criteria. Actual limits, timestamps, identifiers and software versions must come from the test execution and approved project requirements.

4. Generate an HTML report with Python

This example uses only the Python standard library. It reads structured JSON, validates essential fields, calculates a verdict summary and creates an HTML report. Dynamic text is escaped before insertion into HTML.

import json
from collections import Counter
from html import escape
from pathlib import Path

ALLOWED_STATUSES = {
    "PASS", "FAIL", "INCONCLUSIVE", "SKIPPED", "ERROR"
}

def load_results(path: Path) -> list[dict]:
    data = json.loads(path.read_text(encoding="utf-8"))

    if not isinstance(data, list):
        raise ValueError("Expected a JSON array of test results")

    required = {"test_id", "requirement_id", "status"}
    for index, record in enumerate(data):
        if not isinstance(record, dict):
            raise ValueError(f"Record {index} is not an object")

        missing = required - record.keys()
        if missing:
            raise ValueError(
                f"Record {index} is missing: {sorted(missing)}"
            )

        if record["status"] not in ALLOWED_STATUSES:
            raise ValueError(
                f"Unsupported status in record {index}: "
                f"{record['status']}"
            )

    return data


def build_report(records: list[dict]) -> str:
    counts = Counter(record["status"] for record in records)

    rows = []
    for record in records:
        rows.append(
            "<tr>"
            f"<td>{escape(str(record['test_id']))}</td>"
            f"<td>{escape(str(record['requirement_id']))}</td>"
            f"<td>{escape(str(record['status']))}</td>"
            f"<td>{escape(str(record.get('failure_reason') or ''))}</td>"
            "</tr>"
        )

    summary = " | ".join(
        f"{status}: {counts.get(status, 0)}"
        for status in sorted(ALLOWED_STATUSES)
    )

    return f"""<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>ECU Test Report</title>
  <style>
    body {{ font-family: Arial, sans-serif; margin: 2rem; }}
    table {{ border-collapse: collapse; width: 100%; }}
    th, td {{ border: 1px solid #ccc; padding: 0.6rem; text-align: left; }}
    th {{ background: #eee; }}
  </style>
</head>
<body>
  <h1>ECU Test Report</h1>
  <p>{escape(summary)}</p>
  <table>
    <thead><tr>
      <th>Test ID</th><th>Requirement</th>
      <th>Status</th><th>Failure reason</th>
    </tr></thead>
    <tbody>{''.join(rows)}</tbody>
  </table>
</body>
</html>"""


if __name__ == "__main__":
    input_file = Path("results.json")
    output_file = Path("test-report.html")

    results = load_results(input_file)
    report_html = build_report(results)
    output_file.write_text(report_html, encoding="utf-8")

    print(f"Generated {output_file} for {len(results)} test records")

This is a compact reporting example, not a complete production framework. A production pipeline should also validate timestamp formats, measurement types and artifact references; record the generator version; and define behavior for empty, incomplete or interrupted runs.

5. Calculate meaningful test statistics

A report should show the count of every outcome, not just a pass percentage. Keep these categories visible:

  • PASS: all defined acceptance checks passed.
  • FAIL: observed ECU behavior violated an acceptance criterion.
  • INCONCLUSIVE: available evidence is insufficient for a valid product verdict.
  • SKIPPED: the test was intentionally not executed.
  • ERROR: execution or infrastructure prevented a valid test result.

If a pass rate is displayed, define its denominator. For example, a project may calculate pass rate as PASS / (PASS + FAIL), while separately reporting skipped, inconclusive and error counts. Never silently remove non-pass outcomes from the summary.

6. Link traces and supporting artifacts safely

Automotive test evidence may include BLF traces, CAN logs, screenshots, diagnostic logs, measurement exports and test-runner output.

Recommended practices:

  1. Store large files separately from the HTML report.
  2. Link artifacts using controlled relative paths or an artifact-service identifier.
  3. Verify that each referenced file exists before publishing the report.
  4. Prevent path traversal when resolving user- or runner-supplied paths.
  5. Preserve original files and avoid modifying raw trace evidence during report generation.
  6. Record file size, checksum or immutable artifact ID when required by the project.
  7. Apply access controls and retention rules to logs that may contain sensitive vehicle or customer data.

Do not embed arbitrary file paths or raw log content directly into HTML. Escape displayed text and validate artifact destinations.

7. Handle incomplete and abnormal runs

Report generation must not hide partial execution. Consider these conditions:

ConditionRecommended report behavior
Missing required fieldReject or quarantine the malformed record and report the validation error
Duplicate test recordApply a documented uniqueness rule; do not silently overwrite
Test runner interruptedMark the run incomplete and preserve completed records
Missing trace fileShow the missing artifact explicitly
Unknown verdictFlag schema/version incompatibility
Invalid timestamp or timezoneReport a data-quality error rather than guessing
Empty test runGenerate an explicit no-results or incomplete-run status
HTML rendering failurePreserve source JSON and log the generation error

A report should distinguish test execution failures from report-generation failures. A failed renderer must never turn an ECU test into a pass.

8. Verification matrix for the reporting pipeline

Test areaInput or conditionExpected result
Valid dataComplete result recordsReport contains all test records
Missing fieldRequired ID or status absentValidation error is visible
Invalid verdictUnsupported status valueRecord is rejected or quarantined
HTML injectionLog text contains markup charactersText is displayed safely, not executed
Duplicate IDsRepeated test identityDocumented duplicate handling
TimezoneTimestamps with different offsetsOriginal offsets are preserved or normalized consistently
Artifact linkReferenced file does not existMissing artifact is flagged
Partial runRunner stops before all tests finishRun is marked incomplete
Large runMany records and artifactsReport remains usable and generation is measured
RepeatabilitySame input and generator versionEquivalent report content is produced

9. Common implementation mistakes

  • Mixing execution and presentation: makes the test runner difficult to maintain.
  • Keeping only the HTML: loses machine-readable source data needed for later analysis.
  • Counting only completed tests: can hide errors, skipped tests and incomplete runs.
  • Unescaped log content: can create HTML injection vulnerabilities.
  • Broken artifact links: make the report poor evidence for debugging.
  • Missing software/configuration metadata: prevents reliable comparison between runs.
  • Guessing timezones: can make event ordering and latency analysis misleading.
  • Overwriting previous reports: destroys traceability between test executions.
  • Treating report creation as a test pass: report generation and ECU verdicts are separate outcomes.

10. Recommended implementation workflow

  1. Agree on a versioned result schema with the test automation team.
  2. Capture test metadata and verdicts directly from the runner.
  3. Preserve raw results as immutable JSON or another structured format.
  4. Validate required fields, types, timestamps and verdict values.
  5. Aggregate all outcomes with clearly defined statistics.
  6. Check and link the trace/log artifacts.
  7. Render HTML from escaped, validated data.
  8. Archive the input data, report, generator version and artifacts together.
  9. Test the report pipeline with malformed, partial and large result sets.

11. Engineering checklist

  • Result schema is documented and versioned.
  • Each test has a stable ID and requirement reference.
  • ECU software, bench and configuration metadata are recorded.
  • Verdict categories and pass-rate denominator are explicit.
  • Raw machine-readable results are retained.
  • Dynamic HTML content is escaped.
  • Artifact references are validated and access-controlled.
  • Timezone and incomplete-run behavior are defined.
  • Report-generation errors are separate from ECU test verdicts.
  • Reports can be reproduced from archived inputs and generator version.

12. Check your understanding

  1. Why should structured test results be stored separately from the HTML report?
  2. Why is it misleading to calculate pass rate while silently excluding skipped and error cases?
  3. What security risk is reduced by escaping test names and log excerpts before rendering HTML?
  4. Which metadata is needed to compare test results from two ECU software builds?
  5. How should a report represent a test run interrupted before completion?

Related articles

Further reading