Repository navigation
Description
In the following example is situation, when class name is not fully included in resulting TRX report. Only the namespace of the class is included, but the class name is missing. There are newest packages for MTP (2.0.1) and NUnit3TestAdapter (6.0.0-beta.1). But the problem was firstly recognized by me on MTP/1.8.1 and NUnit3TestAdapter/5.0.1. I also checked NET 8 and NET 10 rc1 frameworks, issue is reproducible on both.
In the TRX report for both instances of the Test1 test is only className="One", when running using MTP.
The TRX report fragment:
<UnitTest name="Test1" storage="d:\git\mtp\one\bin\debug\net10.0\one.dll" id="f250b33b-8a35-b41a-e7bf-8e9547f93a26">
<Execution id="983facad-df20-4239-a725-afd3d6150424" />
<TestMethod codeBase="D:\Git\MTP\One\bin\Debug\net10.0\One.dll" adapterTypeName="executor://NUnitExtension/1.0.0+c7d97261880dc4b9bcf3f48c2cabc5293016adba" className="One" name="Test1" />
</UnitTest>
Execution command: dotnet exec One\bin\Debug\net10.0\One.dll --results-directory TestResults --report-trx
On the other side, when same example is executed by vstest.console.exe command, the TRX report contains proper className="One.Tests(One)" and className="One.Tests(Two)".
The TRX report fragment:
<TestDefinitions>
<UnitTest name="Test1" storage="d:\git\mtp\one\bin\debug\net10.0\one.dll" id="31e09d51-24f9-f1bf-3546-ea0d27e9d1e2">
<Execution id="205cb3bb-29b2-47ff-8f7a-16721f04c50a" />
<TestMethod codeBase="D:\Git\MTP\One\bin\Debug\net10.0\One.dll" adapterTypeName="executor://nunit3testexecutor/" className="One.Tests(One)" name="Test1" />
</UnitTest>
<UnitTest name="Test1" storage="d:\git\mtp\one\bin\debug\net10.0\one.dll" id="b28b10d5-d1e1-b8e3-f896-8c4751d57b96">
<Execution id="8cd2ab2d-6490-4b08-8438-500a777931a3" />
<TestMethod codeBase="D:\Git\MTP\One\bin\Debug\net10.0\One.dll" adapterTypeName="executor://nunit3testexecutor/" className="One.Tests(Two)" name="Test1" />
</UnitTest>
</TestDefinitions>
Execution command: vstest.console.exe One\bin\Debug\net10.0\One.dll /logger:trx
In the example code bellow there are two TestFixtureData provider methods, one with used SetArgDisplayNames method, and one without. Reports above are from usage the one with custom test data names GetTestCasesWithNames. But this has no impact on the results. Even if test data contains custom name or not, or even if TestFixture attributes is used directly with parameters, in all cases the .Tests(One) or .Tests(1) is missing from the TRX report's TestMethod node className attribute value (when MTP is used, old vstest.console.exe runner works without issues in all cases).
I don't know if this issue is in MTP or NUnit3TestAdapter code, but I guess the NUnit3TestAdapter one, because the strange behavior is triggered by usage of parametrized fixture attributes.
I think this issue is quite critical, because it prevents usage of parametrized fixtures in MTP. When class name is not fully recognized in TRX report, we cannot map the test result to proper source file and address possible issues. It also leads to test method name misidentification because the class name is missing from the full tests name. It is nowhere in TRX report.
Example unit test class - UnitTest1.cs
using NUnit.Framework;
using System.Collections;
namespace One
{
//[TestFixture(1)]
//[TestFixture(2)]
//[TestFixtureSource(nameof(GetTestCases))]
[TestFixtureSource(nameof(GetTestCasesWithNames))]
public class Tests
{
private int _counter;
public Tests(int counter)
{
_counter = counter;
}
[Test]
public void Test1()
{
Console.WriteLine($"Test1:{_counter}");
Assert.Pass();
}
private static IEnumerable<TestFixtureData> GetTestCases()
{
yield return new TestFixtureData(1);
yield return new TestFixtureData(2);
}
private static IEnumerable<TestFixtureData> GetTestCasesWithNames()
{
yield return new TestFixtureData(1).SetArgDisplayNames("One");
yield return new TestFixtureData(2).SetArgDisplayNames("Two");
}
}
}
Example project file - One.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<EnableNUnitRunner>true</EnableNUnitRunner>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.8.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.1" />
<PackageReference Include="Microsoft.Testing.Extensions.Telemetry" Version="2.0.1" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.0.1" />
<PackageReference Include="Microsoft.Testing.Extensions.VSTestBridge" Version="2.0.1" />
<PackageReference Include="Microsoft.Testing.Platform" Version="2.0.1" />
<PackageReference Include="Microsoft.Testing.Platform.MSBuild" Version="2.0.1" />
</ItemGroup>
</Project>
Activity
OsirisTerje commentedon Nov 5, 2025
Can you enable the Dump (runsettings) and look at the results there? If the same results are there, it is in the framework, if it is correct there, it is the adapter.
https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html#dumpxmltestdiscovery-and-dumpxmltestresults
Also, if you skip using MTP, does it then work as expected?
PS:
This indicates it is related to using MTP at least.
radim-bernatik-veeam commentedon Nov 5, 2025
Here is the output from dump file:
Looks like the information is in the dump in correct form
fullname='One.Tests(One).Test1',classname='One.Tests'. But I am not export on the dump file format, I used it for the first time now.What do you exactly mean by this? Isn't running using vstest.console.exe enough? When running through vstest.console, the TRX report contain correct values for parametrized fixture.
OsirisTerje commentedon Nov 5, 2025
Thanks! The dump information is fine.
That narrows down the issue to be either in the adapter or in the MTP.
It is a strong indication that MTP has something to do with this. But, there are differences between running dotnet test and vstestconsole. You can turn off MTP in the csproj file too, and still use the test explorer and dotnet test.
OsirisTerje commentedon Nov 5, 2025
Repro added here: https://github.com/nunit/nunit3-vs-adapter.issues/tree/master/Issue1351 (Thanks for the repro code @radim-bernatik-veeam !)
@Youssef1313 The dump file have the correct names, and the adapter itself doesn't change the names, it just sends them further.
I haven't debugged through this yet, but nice if you can comment on whether this can be in the bridge or the mtp itself.
radim-bernatik-veeam commentedon Nov 5, 2025
I have made additional test. Switched to NET 8 (vstest mode is not supported in NET 10 at all), set the
<TestingPlatformDotnetTestSupport>false</TestingPlatformDotnetTestSupport>in csproj file and rundotnet test --logger trxcommand.The tests were executed in vstest mode through dotnet test command. Result in TRX is correct. So it is really connected to MTP.
Youssef1313 commentedon Nov 5, 2025
The FQN given to MTP by NUnit is:
Is that really expected?
radim-bernatik-veeam commentedon Nov 6, 2025
Yes, I think
Issue1351.Tests(One).Test1is expected. The namespace isIssue1351, class name isTests, the parameter is given by TestFixtureSource attribute with data from GetTestCasesWithNames function where data are named bySetArgDisplayNames("One"), thus the test class name is expanded by(One). The tests itself isTest1, of course.If I understand correctly, the problem is then in MTP, not in NUnit adapter. Am I right?
Youssef1313 commentedon Nov 6, 2025
A FQN isn't supposed to have parameters in the first place. So it's an unexpected NUnit behavior.
We might consider implementing a workaround for that in VSTestBridge. Such workaround might end up breaking F# scenarios though, where parentheses can be part of identifier names.
OsirisTerje commentedon Nov 8, 2025
In NUnit a test may have any name (not quite true, but nearly so), it is not strictly following C# FQN. However, it most cases it does follow the FQN, and most of the variations are like shown above.
The typical names are like:
MyTest()MyNamespace.MyClass.MyTestOuter.Inner.MyTest()MyNamespace.Outer+Inner.MyTestGenericTests<int>.MyTest()MyNamespace.GenericTests<System.Int32>.MyTestMyTest<int>()MyNamespace.MyClass.MyTest<System.Int32>[TestCase(1, "A")]MyNamespace.MyClass.MyTest(1,"A")[TestFixture(42)]MyNamespace.MyFixture(42).MyTest[TestFixture(typeof(int))][TestCase(1)]MyNamespace.GenericFixture<System.Int32>.MyTest(1)So the case above is (6).
In addition, you can set the name to practically anything you like, but in the most weird cases that will not even pass through the adapter. Only the NUnit.Console and NUnitLite can make sense of those.
Youssef1313 commentedon Nov 8, 2025
This would be resolved if you provide ManagedType/ManagedMethod on your end (#1259). Otherwise, we need some way that let you to provide the bridge with the "correct" class name and method name.
OsirisTerje commentedon Nov 8, 2025
What would the ManageType and ManagedMethod be of this: MyNamespace.MyFixture(42).MyTest
Youssef1313 commentedon Nov 8, 2025
It's whatever
ManagedNameHelper.GetManagedNamereturns. You don't need to calculate it yourself.OsirisTerje commentedon Nov 21, 2025
Ok, so we could just add these in the adapter, right ? Not sure why that would help, but whatever.....
1 remaining item
Youssef1313 commentedon Dec 4, 2025
I'm thinking of considering new VSTestBridge-specific properties for providing this information. See microsoft/testfx#5476. This will still require changes on NUnit side.
radim-bernatik-veeam commentedon Apr 1, 2026
It is 4 months stale, any progress or ETA?
Youssef1313 commentedon Apr 1, 2026
We added new API,
VSTestBridgedTestFrameworkBase.AddAdditionalProperties, which allows custom bridged frameworks (e.g, NUnit) to provide additional properties. NUnit might be able to use that to provideTestMethodIdentifierProperty. If NUnit is able to provideTestMethodIdentifierProperty, we can adjust TRX to consider it instead ofTrxFullyQualifiedTypeNameProperty. UntilTestMethodIdentifierPropertygets added by NUnit, it's NUnit work that needs to be done.radim-bernatik-veeam commentedon Jun 4, 2026
I see that Prefer setting TrxFullyQualifiedTypeNameProperty per TestMethodIdentifierProperty in microsoft/testfx is merged, but can we start using it?
Unfortunately the microsoft/testfx repository is quite weird because they are releasing testfx and MTP from the same repo. There are tags for testFX, but no tags for MTP releases. So I can't see if the merged PR is released or not.
Another issue is the comment from above PR "Once NUnit adds TestMethodIdentifierProperty". I am not able to search any issue or source code in NInit where TestMethodIdentifierProperty is mentioned. So it looks like NUnit does not even know about it.
Youssef1313 commentedon Jun 4, 2026
@radim-bernatik-veeam The above PR you can see it's included in v4.2.1 tag. That corresponds to MTP 2.2.1 as we always ship MSTest 4.x and MTP 2.x together with exactly the same minor and patch versions. So the above PR is already available.
You can also see MTP changelog here: https://github.com/microsoft/testfx/blob/main/docs/Changelog-Platform.md
Youssef1313 commentedon Jun 4, 2026
Yes and that's a problem. NUnit should start creating this property.
OsirisTerje commentedon Jun 7, 2026
@Youssef1313 @radim-bernatik-veeam
Pr #1449 is a fix for this. Please review it. I have enclosed the resulting trx file there, please check if it is as expected.
radim-bernatik-veeam commentedon Jun 8, 2026
@OsirisTerje, @Youssef1313
I did a tests using the branch Issue1351 and the issue is solved only partly. In my tests I used original code which is posted here at the start, NUnit version 4.4.0, MTP version 2.2.3. Executed command
dotnet exec One\bin\Debug\net8.0\One.dll --results-directory TestResults --report-trx --report-trx-filename One-bin-Debug-net8.0-One.trx --ignore-exit-code 8 --output Detailed --no-ansi.In the generated TRX report for NUnitTestAdapter version 6.2.0 (latest nuget) we can see that class name is invalid (of course, no fix is there):
When I replaced NUnit3.TestAdapter.dll with the one from the branch, className attribute value changed and now includes the class name with namespace (One.Tests) and not only namespace like the version before fix (One). But still it does not include the parametrized part.
The final solution (maybe once NUnit do its part?) should be
className="One.Tests(One)"andclassName="One.Tests(Two)".OsirisTerje commentedon Jun 9, 2026
@radim-bernatik-veeam Good point. Have added parameters to the MTP property. Please check now.
PS_ Copied your cases into the repro code at Issue1351 in the repro repo for the adapter.
radim-bernatik-veeam commentedon Jun 10, 2026
@OsirisTerje
I have tested the new version from branch and it looks good. Named parameters works, also automatic names using argument values works as well.
I consider this fix in the branch as the one which is fixing this issue.
Fix duplicate RTD nodes for parameterized fixtures under MTP (#1514)