Skip to content
Open
Changes from all commits
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
38 changes: 38 additions & 0 deletions docs/articles/vs-test-adapter/Tips-And-Tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Certain NUnit Test Adapter settings are configurable using a .runsettings file.
| [OutputXmlFolderMode](#outputxmlfoldermode) | enum | UseResultDirectory,RelativeToResultDirectory,RelativeToWorkFolder,AsSpecified | RelativeToWorkFolder |
| [DumpXmlTestDiscovery](#dumpxmltestdiscovery-and-dumpxmltestresults) | bool | Enable dumping of NUnit discovery response xml | false |
| [DumpXmlTestResults](#dumpxmltestdiscovery-and-dumpxmltestresults) | bool | Enable dumping of NUnit execution response xml | false |
| [DumpNumberedFiles](#dumpnumberedfiles) | bool | Keep the execution dump of every run, in numbered files (from 6.4) | false |
| [PreFilter](#prefilter) | bool | Enable pre-filtering to increase performance for Visual Studio testing | false |
| [ShowInternalProperties](#showinternalproperties) | bool | Turn on showing internal NUnit properties in Test Explorer | false |
| [Where](#where) | string | NUnit Filter expression | |
Expand Down Expand Up @@ -153,6 +154,22 @@ adapter is done, to disk. It is part of the diagnostics tools for the adapter.
current output folder, in a sub-folder named Dump. (Note: This is not the same as the TestResults folder, this data is
not test results, but diagnostics dumps)

#### DumpNumberedFiles

From version 6.4. By default each run overwrites the execution dump of the previous run. Set `DumpNumberedFiles` to
`true` together with `DumpXmlTestResults` to keep the dump of every run: the first run writes `E_x.dll.dump`, the next
`E_x.dll(1).dump`, then `E_x.dll(2).dump`, and so on. This is useful when you run tests one by one from Test Explorer
and want to compare the dumps.

```xml
<RunSettings>
<NUnit>
<DumpXmlTestResults>true</DumpXmlTestResults>
<DumpNumberedFiles>true</DumpNumberedFiles>
</NUnit>
</RunSettings>
```

#### PreFilter

A pre-filter will improve performance when testing a selection of tests from the Test Explorer. It is default off,
Expand Down Expand Up @@ -418,6 +435,27 @@ A value of 0 means no limit is applied. This corresponds to the NUnit [MaxTime a

---

### Filtering with `dotnet test --filter`

The adapter converts a VSTest filter, such as `dotnet test --filter "FullyQualifiedName=..."`, into an NUnit filter.
From version 6.4 it follows the VSTest escaping rules:

* The characters `\ ( ) & | = ! ~` in a value are escaped with a backslash, for example
`FullyQualifiedName=My.Tests.Check\("a\|b"\)`. A backslash that escapes nothing, such as `\P`, is a filter
error, as in VSTest.
* A value runs to the next unescaped operator, spaces included, so `FullyQualifiedName=My.Tests.Method (Case 1)`
selects a test whose name has a space before the argument list.
* Unescaped parentheses directly after a name are still read as its argument list, so `Name=Foo(1)` works without
escaping.
* Under Microsoft Testing Platform, a filter the adapter cannot read is reported as `Invalid test filter, no tests are
run: ...`, and no tests run. Earlier versions crashed the test host.

NUnit writes some characters in a test name as the text `\uXXXX`: control characters, U+0080 to U+009F except U+0085,
unpaired surrogates, U+FFFE and U+FFFF. Such a test is listed with that text in its name, for example
`My.Tests.Check("a\u001bb")`. From version 6.4 a filter with that name selects the test, also from Test Explorer.
In the filter the name is escaped like any other value, the backslash included:
`FullyQualifiedName=My.Tests.Check\("a\\u001bb"\)`.

### Some further information on directories

(From [comment on issue 575](https://github.com/nunit/nunit3-vs-adapter/issues/575#issuecomment-445786421) by
Expand Down
Loading