Skip to content

Commit 1a5e446

Browse files
Add information on tracing in adapter (#1016)
* add information tracing in adapter * auto-fix all linting errors --------- Co-authored-by: Sean Killeen <SeanKilleen@gmail.com>
1 parent 013b956 commit 1a5e446

File tree

3 files changed

+164
-1
lines changed

3 files changed

+164
-1
lines changed

docs/articles/vs-test-adapter/Debugging.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Debugging the NUnit3TestAdapter
22

3+
## Enable Tracing
4+
5+
Before debugging the adapter, check the trace outputs, which can be enabled using runsettings, either from a file or
6+
the command line.
7+
8+
Enable the following [features](https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html#dumpxmltestdiscovery-and-dumpxmltestresults):
9+
10+
```xml
11+
<DumpXmlTestDiscovery>true</DumpXmlTestDiscovery>
12+
<DumpXmlTestResults>true</DumpXmlTestResults>
13+
```
14+
15+
This will create a Dump folder under the executing bin directory, containing one file for each setting. These files
16+
include both the input from the testhost and the resulting data returned by the framework/engine.
17+
18+
## Enabling debugging
19+
320
Debugging the adapter is done by first creating a debug version of the adapter.
421
You can then enable a debug run by passing one of the NUnit debug settings using runsettings.
522

@@ -19,7 +36,8 @@ From command line, you can set these by adding
1936
dotnet test -- NUnit.DebugExecution=true
2037
```
2138

22-
If you want to do this using Visual Studio, you must add a runsettings file, and add these settings there to the NUnit section.
39+
If you want to do this using Visual Studio, you must add a runsettings file, and add these settings there to the NUnit
40+
section.
2341

2442
A detailed explanation of the process can be found in [this blog post](https://hermit.no/debugging-the-nunit3testadapter-take-2/)
2543

docs/snippets/Snippets.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Snippets.NUnit", "Snippets.
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6E5F0945-D524-45AB-AF2C-EFEB7B9CDB97}"
99
ProjectSection(SolutionItems) = preProject
10+
naming.runsettings = naming.runsettings
1011
nuget.config = nuget.config
1112
EndProjectSection
1213
EndProject

docs/snippets/naming.runsettings

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- For more information, see https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019 -->
3+
4+
<RunSettings>
5+
<RunConfiguration>
6+
<!-- See https://github.com/microsoft/vstest-docs/blob/master/docs/configure.md -->
7+
<!-- 1. Test related settings -->
8+
<!-- [x86] | x64: architecture of test host -->
9+
<!--<TargetPlatform>x86</TargetPlatform>-->
10+
11+
<!-- Framework35 | [Framework40] | Framework45 -->
12+
<!--<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>-->
13+
14+
<!-- Path to Test Adapters -->
15+
<!--<TestAdaptersPaths>%SystemDrive%\Temp\foo;%SystemDrive%\Temp\bar</TestAdaptersPaths>-->
16+
<TreatTestAdapterErrorsAsWarnings>false</TreatTestAdapterErrorsAsWarnings>
17+
18+
<!-- Path relative to solution directory -->
19+
<ResultsDirectory>.\TestResults</ResultsDirectory>
20+
21+
<!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
22+
<MaxCpuCount>0</MaxCpuCount>
23+
24+
<!-- TestSessionTimeout was introduced in Visual Studio 2017 version 15.5 -->
25+
<!-- Specify timeout in milliseconds. A valid value should be >= 0. If 0, timeout will be infinity-->
26+
<TestSessionTimeout>10000</TestSessionTimeout>
27+
28+
<!-- Specify a Boolean value, which defines the exit code when no tests are discovered.-->
29+
<TreatNoTestsAsError>false</TreatNoTestsAsError>
30+
31+
<!-- STA | MTA default is STA for .NET Full and MTA for .NET Core-->
32+
<!--<ExecutionThreadApartmentState>STA</ExecutionThreadApartmentState>-->
33+
34+
<!-- Disables in-assembly parallel execution, applies to both MSTest and NUnit -->
35+
<DisableParallelization>false</DisableParallelization>
36+
<DisableAppDomain>false</DisableAppDomain>
37+
<CollectSourceInformation>true</CollectSourceInformation>
38+
39+
<!-- Runner related configuration -->
40+
<BatchSize>10</BatchSize>
41+
42+
</RunConfiguration>
43+
44+
<!-- <DataCollectionRunSettings>
45+
<DataCollectors> -->
46+
<!-- This option can help you isolate a problematic test that causes a test host crash. Running the collector creates an output file (Sequence.xml) in TestResults, which captures the order of execution of the test before the crash. -->
47+
<!-- See https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#blame-data-collector-->
48+
<!-- <DataCollector friendlyName="blame" enabled="True">
49+
</DataCollectors> -->
50+
<!-- </DataCollectionRunSettings> -->
51+
52+
<!--
53+
<TestRunParameters>
54+
<Parameter name="webAppUrl" value="http://localhost" />
55+
<Parameter name="webAppUserName" value="Admin" />
56+
</TestRunParameters> -->
57+
58+
<!-- Section for loggers, see https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019#loggerrunsettings-element
59+
<LoggerRunSettings>
60+
<Loggers>
61+
<Logger friendlyName="console" enabled="True">
62+
<Configuration>
63+
<Verbosity>quiet</Verbosity>
64+
</Configuration>
65+
</Logger>
66+
<Logger friendlyName="trx" enabled="True">
67+
<Configuration>
68+
<LogFileName>foo.trx</LogFileName>
69+
</Configuration>
70+
</Logger>
71+
<Logger friendlyName="html" enabled="True">
72+
<Configuration>
73+
<LogFileName>foo.html</LogFileName>
74+
</Configuration>
75+
</Logger>
76+
</Loggers>
77+
</LoggerRunSettings>
78+
-->
79+
80+
81+
<!-- Adapter Specific sections -->
82+
83+
<!-- MSTest adapter -->
84+
<MSTest>
85+
<MapInconclusiveToFailed>false</MapInconclusiveToFailed>
86+
<CaptureTraceOutput>true</CaptureTraceOutput>
87+
<DeleteDeploymentDirectoryAfterTestRunIsComplete>true</DeleteDeploymentDirectoryAfterTestRunIsComplete>
88+
<DeploymentEnabled>true</DeploymentEnabled>
89+
<DeployTestSourceDependencies>true</DeployTestSourceDependencies>
90+
<MapNotRunnableToFailed>false</MapNotRunnableToFailed>
91+
<EnableBaseClassTestMethodsFromOtherAssemblies>false</EnableBaseClassTestMethodsFromOtherAssemblies>
92+
<!-- <TestTimeout>5000</TestTimeout> -->
93+
94+
<!-- Uncomment and update path for assembly resolution -->
95+
<!-- <AssemblyResolution>
96+
<Directory path="D:\myfolder\bin\" includeSubDirectories="false"/>
97+
</AssemblyResolution> -->
98+
<ForcedLegacyMode>false</ForcedLegacyMode>
99+
<!--
100+
<SettingsFile>a .testsettings file (require ForcedLegacyMode true) </SettingsFile>
101+
-->
102+
</MSTest>
103+
104+
<!-- NUnit3 adapter, uncomment sections to set as appropriate, numeric, booleans, enums have their default values below, except RandomSeed -->
105+
<!-- For documentation, see https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html -->
106+
<NUnit>
107+
<!--<BasePath>D:\Dev\NUnit\nunit3-vs-adapter\demo\NUnitTestDemo\bin\Release</BasePath>-->
108+
<!--<PrivateBinPath>extras;more.extras</PrivateBinPath>-->
109+
<DefaultTimeout>0</DefaultTimeout>
110+
<!--<WorkDirectory>work</WorkDirectory>-->
111+
<InternalTraceLevel>Off</InternalTraceLevel>
112+
<!--<RandomSeed>1234567</RandomSeed>-->
113+
<NumberOfTestWorkers>-1</NumberOfTestWorkers>
114+
<Verbosity>0</Verbosity>
115+
<!--<UseVsKeepEngineRunning>false</UseVsKeepEngineRunning>-->
116+
<!--<ShadowCopyFiles>false</ShadowCopyFiles>-->
117+
<DefaultTestNamePattern>{m}</DefaultTestNamePattern>
118+
<!--<DomainUsage>Single</DomainUsage>-->
119+
<DumpXmlTestDiscovery>false</DumpXmlTestDiscovery>
120+
<DumpXmlTestResults>true</DumpXmlTestResults>
121+
<ShowInternalProperties>false</ShowInternalProperties>
122+
<!--<TestOutputXml>TestOutputXml</TestOutputXml>-->
123+
<!--<Where></Where>-->
124+
<!-- NUnit filter expression, see https://docs.nunit.org/articles/nunit/running-tests/Test-Selection-Language.html -->
125+
<ConsoleOut>1</ConsoleOut>
126+
<UseTestNameInConsoleOutput>true</UseTestNameInConsoleOutput>
127+
<StopOnError>false</StopOnError>
128+
<SkipNonTestAssemblies>false</SkipNonTestAssemblies>
129+
<MapWarningTo>Skipped</MapWarningTo>
130+
<!--Passed, Failed or Skipped-->
131+
<DisplayName>Name</DisplayName>
132+
<!--Name, FullName or FullNameSep-->
133+
<FullnameSeparator>:</FullnameSeparator>
134+
<DiscoveryMethod>Current</DiscoveryMethod>
135+
<!--Legacy or Current-->
136+
<AssemblySelectLimit>2000</AssemblySelectLimit>
137+
<NewOutputXmlFileForEachRun>false</NewOutputXmlFileForEachRun>
138+
<IncludeStackTraceForSuites>true</IncludeStackTraceForSuites>
139+
<ExplicitMode>Strict</ExplicitMode>
140+
<SkipExecutionWhenNoTests>false</SkipExecutionWhenNoTests>
141+
142+
</NUnit>
143+
</RunSettings>
144+

0 commit comments

Comments
 (0)