Skip to content

Test Report

David O'Donoghue edited this page Feb 13, 2026 · 3 revisions

Test Report (Diagnostics)

TestReport automatically captures rich diagnostic data during test sessions. On test failure, it packages screenshots, video recordings, hierarchy snapshots, console logs, and action timelines into a .zip archive for debugging.

How It Works

When a test runs via UIAutomationTestFixture:

  1. Session starts in SetUp() — begins video recording, hooks console output
  2. During the test — captures hierarchy snapshots and screenshots at action start/failure events
  3. Session ends in TearDown() — stops recording, packages everything into a .zip
  4. On failure — the zip is retained; on pass it is deleted (unless UploadPasses is enabled)

Diagnostic Data Captured

Data Description
recording.mp4 Full video of the test at 15 FPS, 1280x720
video_timestamps.csv Per-frame session timestamps for video sync (see below)
screenshot_*.png Screenshots at action start and failure points
hierarchy_*.json Full scene hierarchy with screen-space bounds
session.json Structured timeline: events, logs, metadata
log.txt Plain text Unity console output
persistent_data/ Application.persistentDataPath contents (on failure, optional)

Session JSON Structure

The session.json file contains:

  • events — Action timeline with type, message, timestamp, hierarchy/screenshot references, caller source location
  • logs — All Unity console output (Debug.Log, warnings, errors, exceptions) plus action events with custom log types
  • metadata — Git branch/commit, app version, platform, machine name, screen resolution
  • videoDuration — Duration of the recorded video
  • videoStartOffset — Seconds between session start and recording start (for video-to-log sync)
  • videoTimestampsFile — Filename of the frame timestamp CSV sidecar

Log Types

Console entries use extended log types beyond Unity's built-in set:

Value Type Description
0 Error Debug.LogError
1 Assert Debug.LogAssertion
2 Warning Debug.LogWarning
3 Log Debug.Log
4 Exception Debug.LogException
5 Screenshot Screenshot capture event
6 Snapshot Hierarchy snapshot event
7 ActionStart Test action started
8 ActionSuccess Test action completed successfully
9 ActionWarn Test action warning
10 ActionFailure Test action failed

Hierarchy Snapshots

Hierarchy snapshots capture every GameObject in the scene with:

  • Name, active state, path, instance ID
  • Screen-space bounds (x, y, w, h) for UI elements
  • World-space AABB bounds for 3D objects with Renderers (projected client-side using the VP matrix)
  • Depth ordering (camera distance for 3D, canvas sort order for UI)
  • Camera view-projection matrix for client-side 3D→screen coordinate conversion
  • Component annotations (Button, Toggle, Slider, Text, Image, etc.)
  • Child count and nested children structure

Detailed snapshots (via Snapshot()) additionally capture component property values: text content, colors, font sizes, interactable states, layout settings, and more.

Manual Snapshot

Capture a detailed hierarchy snapshot at any point during a test:

await Snapshot();          // Full depth
await Snapshot(maxDepth: 3); // Limited depth

Persistent Data Capture

When enabled (default: on), Application.persistentDataPath contents are included in the diagnostic zip on test failure. This captures save files, player prefs, logs, etc.

  • Max depth: 3 directory levels
  • Max size: 50 MB total
  • Configure via Edit > Project Settings > UI Automation > Capture Persistent Data on Failure
  • Or programmatically: TestReport.CapturePersistentData = false;

Diagnostic Session Files

Sessions are stored as zip archives in Application.temporaryCachePath/UIAutomation_Diagnostics/.

// Get all diagnostic session zip paths
var sessions = TestReport.GetDiagnosticsFolders();

Custom Metadata

Add project-specific metadata to diagnostic sessions:

TestReport.MetadataCallback = () => new Dictionary<string, string>
{
    { "buildNumber", "123" },
    { "environment", "staging" }
};

VCS Auto-Detection

TestReport automatically detects Git or Plastic SCM branch and commit:

// Disable auto-detection if needed
TestReport.AutoDetectVCS = false;

Video Timestamp Sync

Video recordings may not start at exactly session time zero and can drift due to encoder stalls. To enable accurate video-to-log synchronization, each session includes:

videoStartOffset — The offset (in seconds) between when the test session started and when the recorder began capturing frames. The web viewer uses this to map between session timestamps and video playback position:

videoTime = sessionTime - videoStartOffset
sessionTime = videoTime + videoStartOffset

video_timestamps.csv — A per-game-frame sidecar file that records the session-relative wall-clock time for every frame rendered while the recorder was active. Format: frameIndex,sessionTime (no header, times in seconds). This allows detection of encoder stalls or dropped frames where video time diverges from session time.

See Also

Clone this wiki locally