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
Overloaded [Test] methods in a generic class: both are discovered, only one runs #7207
Two [Test] methods in a generic test class that overload one name are both discovered, but only one of them runs. This happens in both source-generated and reflection modes.
With these in tests/TUnit.TestProject (on the #7199 branch, which also merges #7148), I saw the following:
--list-tests shows both Overloaded(a, 3) and Overloaded(a, b).
A run with --treenode-filter "/*/<namespace>/*/*" reports one fewer test than discovery, and only Overloaded(a, 3) appears among the results. Both modes behave the same.
Suspected cause
The test id (TestIdentifierService.GenerateTestId) includes the method's parameter types. So the two tests most likely end up with the same MethodMetadata.Parameters and therefore the same id, and one of them is then deduplicated. For a generic class, parameter metadata is looked up by method name (ParameterMetadataFactory.ForGenericMethod(type, name, ...)), which could resolve to the first overload. I have not checked whether a non-generic class behaves the same way.
Expected
Both overloads run and report separately, with distinct test ids.
Activity