You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add agent output mode for AI coding agents - #1554
Adds AgentMode (Off | Auto | On, default Auto). Auto turns agent mode on when an AI coding agent is detected from its environment variables. Agent mode only sets defaults; an explicit setting always wins, so the new settings can also be used without agent mode.
Setting
Off (6.3 behaviour)
On
ShowStdout/ShowStderr
All (None if ConsoleOut=0)
Failed
StackTrace
Full
Filtered
Verbosity
0
-1
Failed keeps the output only in the test result, where the VSTest console logger shows it for failed tests. Reasons follow ShowStdout, so in agent mode only reasons of failed tests are sent. Filtered removes NUnit-internal and async state-machine frames. The output decisions are moved into TestOutputPolicy, used by the listener and both converters.
Also fixes: with ShowStderr=Failed, stderr was missing from the test result.
Measured on a repro with 26 tests: console output shrinks by 56 % at minimal verbosity and 63 % at normal. build -t test and build -t acceptance pass locally.
AgentMode (Off | Auto | On) sets output defaults. Auto detects an AI agent
from environment variables. Explicit settings always win.
- ShowStdout/ShowStderr (All | Failed | None): Failed keeps output only in
the test result, which the VSTest console logger shows for failed tests.
- StackTrace (Full | Filtered | None): Filtered removes NUnit-internal and
async state-machine frames.
- Reasons are sent only for failed tests when ShowStdout is Failed.
- TestOutputPolicy centralizes the output decisions for the listener and
both converters.
- Off keeps the 6.3 behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds agent-oriented output defaults to the NUnit VS Adapter to reduce console noise for AI coding tools. This addresses the console-output portion of #1515; result-file support remains separate in #1552.
Changes:
Adds automatic agent detection and configurable output, stack-trace, and verbosity defaults.
Centralizes output decisions in TestOutputPolicy, shared by the listener and both converters.
Documents the settings and adds tests for presets, overrides, and output handling.
Progress output only goes live to the console, so ShowStdout=Failed lost it.
Keep it in the test result for Failed, apply the reason gate to the XML
converter as well, and document that None keeps NUnit's own result output.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved issues suppress failing-fixture diagnostics, remove legitimate MoveNext throw locations, and miss Codex environments that should receive agent defaults.
Issue #1515 requests detection using the same environment variables as MTP, but a Codex environment exposing only CODEX_SANDBOX, CODEX_CI or CODEX_THREAD_ID resolves Auto to Off here. MTP's detector on its current default branch at d54b8f1 recognizes all three alongside CODEX_CLI. Add these aliases so those Codex sessions receive the advertised agent defaults without explicitly setting AgentMode=On.
Suite setup and teardown output is never flushed for failed suites
src/NUnitTestAdapter/NUnitEventListener.cs:270
With ShowStderr=Failed or ShowStdout=Failed, stderr/progress output from OneTimeSetUp or OneTimeTearDown is suppressed and buffered under the suite ID (NUnit's current-test output tagging, default branch). Only TestFinished consumes these buffers, so a failing fixture's diagnostics never reach the console or recorded results. Consume and clear suite-owned buffers in SuiteFinished, reporting suppressed output when the suite fails or attaching it to affected results.
Preserve handwritten MoveNext frames in stack traces
src/NUnitTestAdapter/StackTraceFilter.cs:23
This removes every method named MoveNext, including handwritten enumerators such as at App.CustomEnumerator.MoveNext() in CustomEnumerator.cs:line 42. A failure in that method therefore loses its actual throw location under the agent preset. Require a compiler-generated state-machine type marker before removing a MoveNext frame so ordinary enumerator methods remain visible.
- Detect agents with the environment variables MTP uses, including the Codex
aliases. The list comes from Microsoft.Testing.Platform (MIT); attribution
is in the new THIRD_PARTY_NOTICES.md.
- Send buffered output of a failed OneTimeSetUp/OneTimeTearDown when it was
not sent live, and clear the suite buffers.
- Keep MoveNext frames in filtered stack traces. On .NET Framework the throw
location of an async method is <Method>d__0.MoveNext().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1515.
Adds
AgentMode(Off | Auto | On, defaultAuto).Autoturns agent mode on when an AI coding agent is detected from its environment variables. Agent mode only sets defaults; an explicit setting always wins, so the new settings can also be used without agent mode.Off(6.3 behaviour)OnShowStdout/ShowStderrAll(NoneifConsoleOut=0)FailedStackTraceFullFilteredVerbosity0-1Failedkeeps the output only in the test result, where the VSTest console logger shows it for failed tests. Reasons followShowStdout, so in agent mode only reasons of failed tests are sent.Filteredremoves NUnit-internal and async state-machine frames. The output decisions are moved intoTestOutputPolicy, used by the listener and both converters.Also fixes: with
ShowStderr=Failed, stderr was missing from the test result.Measured on a repro with 26 tests: console output shrinks by 56 % at minimal verbosity and 63 % at normal.
build -t testandbuild -t acceptancepass locally.Docs: nunit/docs#1321. Result file: #1552.
🤖 Made by @OsirisTerje with Claude