fix(commons): use method type parameters in fullNames instead of arguments #572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Both NUnit and xUnit allow for generic test methods:
Currently, Allure NUnit and Allure xUnit.net include the type argument (i.e.,
System.Int32orSystem.String) infullName.Mapping issues
Having
fullNamedepending on method type arguments leads to a single test method having differentfullName(and, consequently,testCaseId) values depending on the types of its arguments. That maps different argument sets of the test method into separate test cases in TestOps, rather than a single test case that encompasses all argument sets.Additionally, this makes the selective run feature trickier to use, as all combinations of argument types need to be known in advance.
Those issues become more annoying in case the argument types can change across runs, e.g., if the values are provided from the outside.
While not significantly affecting Allure 2, these issues will become apparent in Allure 3, where plans are underway to rework how parameterized tests are reported.
fullNamesize issueIn most cases, type arguments are much more verbose than their corresponding type parameters. Some examples:
TSystem.Int32TSystem.StringTSystem.Collections.Generic.List`1[System.String]TMyAssemblyName:MyNamespace.MyClassThe proposal
This PR changes the
fullNamecalculation to be based on generic method definitions instead of constructed generic methods. That replaces all method type arguments with their parameters infullName.Note
Only method type arguments are replaced with their parameters. If the method is defined in a generic type, the
fullNamecontinues including the type arguments of that type. That's because multiple instantiations of the generic type create practically different types with different methods that must each correspond to its own test case.That said, defining test methods in a generic test class is a niche use unique to NUnit. xUnit doesn't support parameterization at the class level and thus doesn't support generic test classes.
The fix doesn't affect non-generic methods.
Checklist