Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions docs/articles/vs-test-adapter/Tips-And-Tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ Certain NUnit Test Adapter settings are configurable using a .runsettings file.
| [AllowParallelWithDebugger](#allowparallelwithdebugger) | bool | Allow parallel execution when debugger is attached | false |
| [ThrowOnEachFailureUnderDebugger](#throwoneachfailureunderdebugger) | bool | Throw on each failure when debugger is attached | false |
| [UseDefaultAssemblyLoadContext](#usedefaultassemblyloadcontext) | bool | Force the engine to use Default Loading Context, otherwise engine decide | true |
| [AgentMode](#agentmode) | enum | Output defaults for AI coding agents, options are `Off`, `Auto` or `On` | Auto |
| [ShowStdout](#showstdout-and-showstderr) | enum | Where standard output goes, options are `All`, `Failed` or `None` | All (Failed in agent mode) |
| [ShowStderr](#showstdout-and-showstderr) | enum | Where error output goes, options are `All`, `Failed` or `None` | All (Failed in agent mode) |
| [StackTrace](#stacktrace) | enum | How stack traces are shown, options are `Full`, `Filtered` or `None` | Full (Filtered in agent mode) |

### Visual Studio templates for runsettings

Expand Down Expand Up @@ -139,6 +143,8 @@ information from the lower numbers. It has the following actual levels:

5: Outputs all debug statements in the adapter

From version 6.4.0, the default is `-1` in [agent mode](#agentmode).

#### UseVsKeepEngineRunning

This setting is used by the adapter to signal to the VSTest.Execution engine to keep running after the tests have
Expand Down Expand Up @@ -260,6 +266,10 @@ dotnet test -- NUnit.ConsoleOut=0

(From version 3.17.0, Modified in 4.2.0)

From version 6.4.0, [ShowStdout and ShowStderr](#showstdout-and-showstderr) replace `ConsoleOut` for choosing where the
output goes. `ConsoleOut` still works: `0` means `None`, and `1` or `2` mean `All`. With `2`, the output is still sent as
Warning.

#### UseTestNameInConsoleOutput

When set to `true`, the default, the name of the test is added as a prefix in front of each console line output. This
Expand Down Expand Up @@ -416,6 +426,66 @@ A value of 0 means no limit is applied. This corresponds to the NUnit [MaxTime a

(From version 6.3)

#### AgentMode

Agent mode reduces the console output for AI coding agents, such as Claude Code, Copilot CLI, Codex or Cursor, so
they use fewer tokens on passing tests. It only changes defaults:

* [ShowStdout and ShowStderr](#showstdout-and-showstderr) become `Failed`
* [StackTrace](#stacktrace) becomes `Filtered`
* [Verbosity](#verbosity) becomes `-1`

A setting you set explicitly, including [ConsoleOut](#consoleout), always wins over these defaults.

The options are:

* `Auto`, the default: agent mode is on when the adapter finds an environment variable set by a known AI coding agent.
The list of variables is the same as the one Microsoft.Testing.Platform uses. A variable set to `0` or `false` does
not count.
* `On`: always agent mode.
* `Off`: always the traditional output.

You can set it on the command line without a runsettings file:

```console
dotnet test -- NUnit.AgentMode=On
```

(From version 6.4.0)

#### ShowStdout and ShowStderr

These settings control where the test output goes. `ShowStdout` is for standard output, including
`TestContext.Progress`, and `ShowStderr` is for error output. The options are:

* `All`: output goes to the console as the tests write it. This is the default, and the same as `ConsoleOut=1`.
Comment thread
OsirisTerje marked this conversation as resolved.
Resolved
* `Failed`: output is kept only in the test result. The VSTest console logger prints it for failed tests only, so the
output of passing tests does not appear in the console. `TestContext.Progress` output also goes to the test result
instead of the console. Output written in a failing `OneTimeSetUp` or `OneTimeTearDown` is sent with the failure
message. This is the default in [agent mode](#agentmode).
Comment thread
OsirisTerje marked this conversation as resolved.
Resolved
* `None`: output is not sent to the console, and not added to the test result. The output that NUnit itself stores in
the test result stays there, the same as with `ConsoleOut=0`.

```console
dotnet test -- NUnit.ShowStdout=Failed NUnit.ShowStderr=Failed
```

(From version 6.4.0)

#### StackTrace

This setting controls how stack traces of failures are shown. The options are:

* `Full`: the complete stack trace. This is the default.
* `Filtered`: frames from `System.Runtime` and from NUnit internals are removed, so the frames from your own code
remain. This is the default in [agent mode](#agentmode).
* `None`: no stack traces.

[IncludeStackTrace](#includestacktrace) and [IncludeStackTraceForSuites](#includestacktraceforsuites) still turn stack
traces off for test cases and suites. If both are false, the default for `StackTrace` is `None`.

(From version 6.4.0)

---

### Some further information on directories
Expand Down
Loading