You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Visual Studio 2022: Test Explorer duplicates each Test with concatenated Namespace #5928
Each test is shown twice with a concatenated namespace
Expected behavior
Each test is only shown once.
Actual behavior
Each test is shown twice.
Additional context
With version <= v1.6.3 of MTP the issue does not exist.
When using nunit with version 4.3.2 the issue does not exist. So this might be a related to xunit.v3, however, the fact that it worked with MTP <= v1.6.3 indicates that something has changed under the hood within the Microsoft Testing Platform.
Thanks for confirmation Lori (@Lorilatschki). This is related to the change we had to take in #5409 which affected xUnit. To give a bit of history, we have had TestMethodIdentifierProperty class with Namespace and TypeName property. The API was intended to be used that Namespace is just the namespace part, and TypeName is just the type name without the namespace.
In the Json RPC protocol that we use to communicate with Visual Studio, we translated Namespace to location.namespace and TypeName to location.type. However, the assumption on Test Explorer side was unfortunate and we couldn't change it. It assumed that location.type will also contain the namespace.
As a result, we have had a discrepancy in assumptions in MTP and VS. Moreover, xUnit was including the namespace as part of TypeName (which wasn't how our public API is intended to be used), and that's where the namespace duplicated come from.
When we aligned MTP with Test Explorer, this unfortunately broke xUnit, but for a good reason, because again, TypeName isn't intended to include the namespace.
The real-time discovery is out of all this, and in this case it has the right namespace and type name. But what the test project sends later to TE is the test cases with the duplicated namespace. And Test Explorer doesn't seem to be capable of throwing away the real-time discovery results and instead merges the two results together, causing this behavior.
The newer version of xunit.v3 handles TestMethodIdentifierProperty correctly, so the actual discovery is now aligned again with real-time discovery and they produce the same results, causing the issue to go away.
I know this might be too much information, but I wanted to give a bit of history.
The short answer is, I would consider the current stable version of xunit.v3 (2.0.3 at the moment) as not compatible with MTP 1.7+.
So, if you use xunit.v3 2.0.3, stick with MTP 1.6. If you are okay using a prerelease of xunit.v3, then you can use MTP 1.7+.
I'm going to close then as there is unfortunately not much to do on our side.
Activity
Youssef1313 commentedon Jul 2, 2025
I'm not able to reproduce it so far, but I'm suspecting it's related to this option:
Can you verify if it's turned on or off for you? And try to turn it off if it's on?
Also can you please try the latest xunit.v3 prerelease?
Lorilatschki commentedon Jul 2, 2025
Thanks for the very fast reply. The setting is turned on
I have turned off the setting, when doing so, the issue disappears.
With
discover tests in real timeon and the latest pre-release ofxunit.v3versionv3.0.0-pre.25the issue also disappears.Youssef1313 commentedon Jul 2, 2025
Thanks for confirmation Lori (@Lorilatschki). This is related to the change we had to take in #5409 which affected xUnit. To give a bit of history, we have had
TestMethodIdentifierPropertyclass withNamespaceandTypeNameproperty. The API was intended to be used thatNamespaceis just the namespace part, andTypeNameis just the type name without the namespace.In the Json RPC protocol that we use to communicate with Visual Studio, we translated
Namespacetolocation.namespaceandTypeNametolocation.type. However, the assumption on Test Explorer side was unfortunate and we couldn't change it. It assumed thatlocation.typewill also contain the namespace.As a result, we have had a discrepancy in assumptions in MTP and VS. Moreover, xUnit was including the namespace as part of
TypeName(which wasn't how our public API is intended to be used), and that's where the namespace duplicated come from.When we aligned MTP with Test Explorer, this unfortunately broke xUnit, but for a good reason, because again,
TypeNameisn't intended to include the namespace.The real-time discovery is out of all this, and in this case it has the right namespace and type name. But what the test project sends later to TE is the test cases with the duplicated namespace. And Test Explorer doesn't seem to be capable of throwing away the real-time discovery results and instead merges the two results together, causing this behavior.
The newer version of xunit.v3 handles
TestMethodIdentifierPropertycorrectly, so the actual discovery is now aligned again with real-time discovery and they produce the same results, causing the issue to go away.I know this might be too much information, but I wanted to give a bit of history.
The short answer is, I would consider the current stable version of xunit.v3 (2.0.3 at the moment) as not compatible with MTP 1.7+.
So, if you use xunit.v3 2.0.3, stick with MTP 1.6. If you are okay using a prerelease of xunit.v3, then you can use MTP 1.7+.
I'm going to close then as there is unfortunately not much to do on our side.
Lorilatschki commentedon Jul 2, 2025
Youssef Fahmy (@Youssef1313) thanks a lot for the detailed information. That helped a lot to understand the root cause. I have closed the issue.