-
Notifications
You must be signed in to change notification settings - Fork 744
SetArgDisplayNames for TestCaseData and TestFixtureData #2536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'd lean to changing the method name to Otherwise, it seems like a good idea. SetName still remains as a more general way to define the name if you don't like the idea of args in parentheses. For example, I have used `SetName("{m}_SomeSuffix") in order to differentiate the case without spelling out args. |
@CharliePoole what do you think about |
I could go that way as well. I wonder if there is a name to use if you don't actually want to put arg names in parentheses, but just something like "Issue-xxxx" or "edge case". In that case you are essentially replacing the display of args. The naming is important but doesn't have to hold you up if you intend to implement this. We can discuss it in the PR. |
It was taking way too long to figure out part of the testing, so I just put the code up for comments: #2538 |
@nunit/framework-team I would like to get this in 3.10. I think it's been ready to go in for a while, and I am not seeing outstanding concerns from any of the participants. (If I'm wrong, please clarify so that we can get this work done.) I updated #2538 to make TestFixtureData.SetName public now that it behaves consistently with TestCaseData.SetName. Would you like me to split the work in my PR into multiple PRs? |
@jnm2 - I've already opened the wine tonight, but will make sure I review in the next few days! 😄 Any chance you could do a quick few lines on old vs new behaviour, and why the change? I'm wary there's been a lot of discussion on this, and don't want to miss something! |
The change in behavior of The commit "Tell-don't-ask to apply test name" moves the test name templating logic into TestParameters so that the builder stops reaching into the parameters and pulling out pieces of data like TestName and ArgNames and deciding how to apply them to the test being built. This allows ArgNames in the next commit to stay protected. (If we allowed C# 7.2, this would have been The commit "Added TestCaseData.SetArgNames" demonstrates implementation of the titular feature in combination with the existing templating The commit "Added TestFixtureData.SetArgNames" demonstrates trivially plugging the building of test fixtures into the same tell-don't-ask ApplyToTest and widens TestNameGenerator to work on |
Finally ran into this again while giving it a fresh start. I need some direction. Which should I shoot for? 1.
|
Personally, I prefer option 1 because it is the least complex and easiest to understand. You say that "No way to do automatic argument length trimming or any name customization besides customizing the argument display names." but that doesn't seem like a problem since you are already specifying the arguments. Am I missing something? The other two options seem more correct, but they increase the complexity dramatically and I expect that different people will expect different things. Personally, I like living with constraints 😄 |
Nope, good point! Overriding the runner's automatic trimming is probably rather a feature, anyway! Thanks for that. I'll start on this as soon as I get some free time. :D |
PR is up: #2919 |
Uh oh!
There was an error while loading. Please reload this page.
Edit:
TestFixtureData.SetName
is being made public again after we pulled it from 3.9 now that the behavior is consistent withTestCaseData
TestCaseData.SetName
leaves you in an impossible situation explored by #1943 if you are forced to customize parameterized test names and the parameter names contain curlies. To summarize:/cc @stewart-r as promised, who said:
Also to say nothing of the escaping problems we ran into with curlies,
SetName
is just plain verbose. The style just about everyone wants to use, and I agree with them, is"{m}(" + string.Join(", ", customParameterNames) + ")"
.We explored different alternatives and this is the only one that addresses all my concerns, @stewart-r's concerns, and @oznetmaster's concerns with the
SetName
being added toTestFixtureSource
(#2529):Usage example for TestFixtureData:
.SetArgDisplay("Issue-2464")
TestCaseData usage example:
Resulting test name:
SetArgDisplay
fills a need that no other solution fills. It's urgent for my real world use cases. If I implement it in time for 3.9, it also allows us to removeTestFixtureData.SetName
until we have a proper discussion about expansions and escaping (and whether we'd even want it). Thus I'm marking this design discussion pri:high.The text was updated successfully, but these errors were encountered: