Test categories aren't propagated to vstest trx logs
See original GitHub issueWith the latest version of the nuni3-adapter unit test descriptions in trx files created with vstest.console (2017) don’t have TestCategory elements.
Expected behaviour
All categories assigned to test cases are reflected in TestCategory elements in trx logs, for example:
<UnitTest name="ThatEmptyContainsHeaders" storage="d:\work\nunit3-vs-adapter\src\nunittestadaptertests\bin\debug\netcoreapp1.0\nunit.visualstudio.testadapter.tests.dll" id="5d22f9c8-13f7-4be4-b020-438dbf715a39">
<TestCategory>
<TestCategoryItem TestCategory="DumpXml" />
</TestCategory>
<Execution id="cf9ffa57-0013-4c9a-877e-5104b828b8ec" />
<TestMethod codeBase="D:\work\nunit3-vs-adapter\src\NUnitTestAdapterTests\bin\Debug\netcoreapp1.0\NUnit.VisualStudio.TestAdapter.Tests.dll" executorUriOfAdapter="executor://nunit3testexecutor/" className="NUnit.VisualStudio.TestAdapter.Tests.DumpXmlTests" name="ThatEmptyContainsHeaders" />
</UnitTest>
Repro steps
- build the nunit3-vs-adapter repo;
- invoke vstest.console with the following arguments. note the logger argument
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "D:\work\nunit3-vs-adapter\src\NUnitTestAdapterTests\bin\Debug\netcoreapp1.0\NUnit.VisualStudio.TestAdapter.Tests.dll" /logger:"trx" /TestAdapterPath:"D:\work\nunit3-vs-adapter\bin\Debug"
- the test will spit out a new result trx-file. Open it in a text editor and note that none of the test cases have TestCategory items, for example:
<UnitTest name="ThatEmptyContainsHeaders" storage="d:\work\nunit3-vs-adapter\src\nunittestadaptertests\bin\debug\netcoreapp1.0\nunit.visualstudio.testadapter.tests.dll" id="c3d0232c-20e9-44be-a6e9-c48b0b4ef694">
<Execution id="7a1b8f5c-23fd-4562-832f-3febbda631f9" />
<TestMethod codeBase="D:\work\nunit3-vs-adapter\src\NUnitTestAdapterTests\bin\Debug\netcoreapp1.0\NUnit.VisualStudio.TestAdapter.Tests.dll" executorUriOfAdapter="executor://nunit3testexecutor/" className="NUnit.VisualStudio.TestAdapter.Tests.DumpXmlTests" name="ThatEmptyContainsHeaders" />
</UnitTest>
Additional thoughts
I believe it is an issue in the TrxLogger itself: https://github.com/Microsoft/vstest/blob/0341da456744f78bba8ff2a25c1cddfc89c87b08/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs#L51 but given that today vstest executable is distributed with a VS only and thus can not be update in reasonable timeframes, would you mind to accept a simple compatibility patch to the adapter to fix the issue?
And vstest still doesn’t support custom traits: https://github.com/Microsoft/vstest/issues/98
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:19 (11 by maintainers)

Top Related StackOverflow Question
@OsirisTerje did you ever hear back from anyone on this? Should we consider a workaround?
@OsirisTerje I think this was the relevant ticket https://github.com/microsoft/vstest/issues/4142