Repository navigation
Description
Summary
Introduce a new MTP extension Microsoft.Testing.Extensions.JsonReport that emits a stable, documented NDJSON (newline-delimited JSON) event stream of test execution events, plus a final summary event. Models the existing Microsoft.Testing.Extensions.TrxReport, Microsoft.Testing.Extensions.HtmlReport, and Microsoft.Testing.Extensions.AzureDevOpsReport extensions.
Motivation
Today MTP offers two machine-readable outputs:
--list-tests json(test discovery only, added in Add --list-tests json for machine-readable test discovery output #8280)- TRX XML via
Microsoft.Testing.Extensions.TrxReport(verbose, schema-heavy, hard to stream)
There is no structured output for test execution results that an agent or downstream tool can stream-parse incrementally. Modern test runners all expose this:
- Jest (
--json): https://jestjs.io/docs/cli#--json - pytest-json-report: https://pypi.org/project/pytest-json-report/
- Vitest (JSON reporter): https://vitest.dev/guide/cli.html#reporters
- Bun test (
--reporter=junitand JSON variants)
For LLM/agent consumption, NDJSON is far superior to TRX:
- One event per line: agents can grep/tail without parsing
- Stable schema: agents can rely on field names
- Streamable: events flush as tests complete, enabling live reactions
Proposed shape
Each line is a single JSON object. Event types:
{"event":"run_started","schemaVersion":1,"runId":"...","startTimeUtc":"...","framework":{"name":"MSTest","version":"3.x"}}
{"event":"test_started","testId":"...","testUid":"...","displayName":"...","fullyQualifiedName":"...","source":"..."}
{"event":"test_completed","testId":"...","outcome":"passed|failed|skipped|inconclusive","durationMs":12.3,"messages":[...],"errors":[{"type":"...","message":"...","stackTrace":"..."}],"output":{"stdout":"...","stderr":"..."},"location":{"file":"...","line":42}}
{"event":"run_summary","schemaVersion":1,"runId":"...","durationMs":1234,"counts":{"total":42,"passed":40,"failed":1,"skipped":1,"inconclusive":0},"endTimeUtc":"..."}Per-test fields are optional and omitted when empty to reduce file size / token count.
CLI surface
--report-json [filename] # writes NDJSON file under results-directory
--report-json-filename <path> # explicit filename
Mirrors --report-trx* / --report-html* exactly.
Implementation outline
- New project:
src/Platform/Microsoft.Testing.Extensions.JsonReport/Microsoft.Testing.Extensions.JsonReport.csproj - Class
JsonReportDataConsumer : IDataConsumerconsumesTestNodeUpdateMessagefrom the message bus (same pattern asTrxDataConsumer). JsonReportCommandLineOptionsProvider : ICommandLineOptionsProviderregisters the two options.- Use
System.Text.JsonUtf8JsonWriterfor AOT-safety and zero-allocation writes. - Document schema in
PACKAGE.mdand adocs/JsonReportSchema.mdpage. - Add
--list-tests jsonwas already added in Add --list-tests json for machine-readable test discovery output #8280; this extension is for execution results.
Risks / questions
- Naming:
JsonReportvsJsonlReportvsEventStreamReport. NDJSON is the format; "JsonReport" matches the existing extension-name pattern (Trx, Html, AzureDevOps). - Should the schema also produce one big JSON document (Jest-style
--json) in addition to NDJSON? NDJSON is strictly more useful for streaming agents; the umbrella issue can debate. - Stability: bump
schemaVersionon breaking changes.
Acceptance criteria
- New package
Microsoft.Testing.Extensions.JsonReportproduced and shipped. --report-jsonand--report-json-filenameoptions registered and visible in--helpwith-extensions snapshot.- Documented schema in
PACKAGE.md+ a versioned schema doc. - Acceptance integration tests: run a known failing+passing test set, assert the NDJSON file has the expected events.
References
- Umbrella: [RFC] Agent/LLM-efficient test output for Microsoft.Testing.Platform #8824
- Existing patterns:
src/Platform/Microsoft.Testing.Extensions.TrxReport/,Microsoft.Testing.Extensions.HtmlReport/,Microsoft.Testing.Extensions.AzureDevOpsReport/ - Related: Add --list-tests json for machine-readable test discovery output #8280 (
--list-tests json) - External: Jest
--json, pytest-json-report, Vitest JSON reporter
Activity
Evangelink commentedon Oct 15, 2026
Evaluation follow-up: reframe around public streaming, not just JSON
At the investigated revision,
6c6b1f474acbb6ab1bdbdec73fa32568f12dfcb5, the repository already contains experimental CTRF JSON execution reporting, including final outcomes, identities and retry history. This narrows the "we need any execution JSON" gap, but does not itself satisfy a stable public streaming contract.Measured comparison
The #8824 local pilot used eight synthetic scenarios, one repeat and a fixed
gpt-6.1-solexecutor, with Vally 0.14.0 / Copilot SDK 1.0.11 / nested CLI 1.0.80. Every arm had the same task, exact grader, run metadata and full terminal fallback.The two query views were effectively tied in this pilot. The NDJSON inputs were prototype files, including module/attempt metadata needed by the cases, not an implemented reporter or agreed schema. This did not test flush latency, streaming, backpressure or time-to-first-action. Provider cost is not the same as total input tokens, raw bytes, USD or energy.
Two separately evaluated real-output cases did not reproduce a consistent saving. All six exact grades passed, but the query path still needed terminal details; two recovered read-path mistakes in one CTRF trial confound its observed cost increase. These are small pilot observations, not statistical evidence that CTRF is intrinsically faster or slower.
Diagnostic fidelity matters more than the format name
An actual packed-host case published a failed node with an exception of this shape, without a richer explanation:
The terminal retained both diagnostics. The actual CTRF test record contained only the outer message and its stack:
SERVICE_AUTH_401was absent. The current shared capture helper takes the provided exception'sMessageandStackTracewithout traversing the inner chain. Other producers can supply richer explanation strings, so this is a specific demonstrated producer shape, not a claim about every framework.The synthetic CTRF fixture had a full multiline message and was therefore more informative than this real report. A query cannot recover information the reporter did not preserve. Keeping terminal fallback, and adding focused diagnostic-preservation coverage, is a higher-confidence next step than assuming a new JSON label solves triage.
Producer overhead was also observable
The controlled net9.0/Windows x64 consumer used the actual locally packed MTP
2.6.0-devand CTRF1.0.0-dev, built with repository SDK12.0.100-alpha.1.26509.101. Feed/cache/package hashes and loaded runtime DLLs were matched.Across pass, failure, nested, zero, all-skipped and recovered-retry scenarios, five interleaved measured samples per mode after warmups showed about 0.49-0.51 seconds extra startup-inclusive wall time with CTRF enabled. For the 1,000-pass case the medians were 437ms off versus 936ms on; terminal output was 286 bytes and the CTRF file 463,863 bytes. This includes reporting/recovery/hosting lifecycle, not isolated JSON serialization cost; the cause was not profiled.
This argues against auto-enabling a report for very short agent loops without measuring the composed path. It does not measure a future NDJSON emitter's overhead.
Suggested direction
Use existing CTRF as a final-results baseline. Pursue a new NDJSON package if a concrete public incremental consumer needs it, and measure correct actionable information arriving before run completion.
Before making that a supported contract, define module/TFM/test/attempt identities, missing start events, all relevant failure states, explicit completion versus missing/truncated summary, bounded serialized writes/backpressure, cancellation/crash behavior, and aggregation across retries/modules. The internal recovery journal and server-mode events are prior art, not public report schemas to expose unchanged.
Also, the current shared report CLI has a zero-argument report switch and a separate one-argument filename switch;
--report-json [filename]does not literally mirror that arity.The real host used a controlled framework, not the MSTest adapter. Repair quality, larger held-out suites, other models/OSes, release branches and live streaming remain unmeasured. Full scripts/traces/CSV are retained locally, not yet published as a reproducible benchmark artifact. No production implementation or issue-state change was made.
Posted by GitHub Copilot at the maintainer's request.
Evangelink commentedon Nov 9, 2026
Closing as not planned. The need for machine-readable test results is valid, but a separate
Microsoft.Testing.Extensions.JsonReportpackage is not justified by the current evidence.Existing paths cover the main use cases
Why not another format now?
The earlier evaluation did not establish an NDJSON-specific accuracy or cost advantage over querying CTRF for failures. The small synthetic pilot's two failure-query views were effectively tied, real-output observations did not show consistent savings, and live streaming was not measured. This is limited evidence, not proof that streaming can never help.
A new format also would not repair diagnostics that were lost before serialization. Improving diagnostic fidelity in existing reporting is a more direct response to that demonstrated problem. A separate reporter would introduce another supported schema and lifecycle contract covering module/test/attempt identities, retries, partial runs, buffering and delivery failures.
Limits and conditions for reconsideration
OTel is not automatically a complete test-results ledger: sampling, queue saturation, attribute limits and interrupted flushing can lose information. Normal span export delivers completed spans, not immediate test-start notifications or each event added to a still-running span. Persisted reports and telemetry serve different purposes.
A lightweight, directly tail-able lifecycle artifact could still be useful. We can reconsider it when a concrete consumer demonstrates a requirement that CTRF, OTel or server mode cannot reasonably meet, with a measurable improvement in useful, correct action before run completion and acceptable producer overhead. Any proposal should define identity, completion versus truncation, and delivery semantics rather than assume NDJSON supplies those guarantees.
This closes the proposed additional package, not future improvements to existing reporters or telemetry.