Skip to content
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

Length of generated test names should be limited #59

Closed
CharliePoole opened this issue Nov 22, 2013 · 14 comments
Closed

Length of generated test names should be limited #59

CharliePoole opened this issue Nov 22, 2013 · 14 comments

Comments

@CharliePoole
Copy link
Contributor

Since NUnit uses the value of a string argument to a test as part of the name, it's possible for the names to be arbitrarily long. This causes problems, particularly in the Gui, where GDI+ exceptions may be thrown and in the VS adapter, which may either reject the name or truncate it arbitrarily.

Names generated in the framework should be limited to a reasonable length <= 449 characters, the length that is enforced by the adapter. However, we don't want to simply truncate the name after generating it. Ideally, each individual parameter should be truncated in a way that limits the overall length of the name while preserving the general outline of FixtureName(args).TestName(args).

Since any truncation may cause duplicate names, which NUnit itself does not mind but which can break some clients like TestExplorer, name generation should include adding a unique value like the test id where needed. Note that it would be possible to use the test id alone for a unique name, but that this would not result in a good user experience in runners (TestExplorer again) that use the test name as a display name.

We may want to provide the raw materials for separating the display name from the "real" unique test name for those runners that want to take advantage of it.

@yetibrain
Copy link

We have the same problem regarding long test names, mostly with parameterized tests. This caused big problems because we use the testnames also as filenames (we have a tool that extracts failed tests from a testresult file in order to re-run just the failed tests) We already shorten long namespaces by using a kind of namespace-prefix instead of the entire name. Concerning parameters, we ran into trouble because a filename cannot have certain characters like double quotes. So we use a regex with a named group to find the parameters and replace the entire parameters with the hashcode of it. In case of ambiguous names we add simply numbers to the end of the name.

@CharliePoole
Copy link
Contributor Author

See issue #68 which should be worked in tandem with this one.

@CharliePoole CharliePoole added this to the 3.0 milestone Mar 2, 2014
@CharliePoole
Copy link
Contributor Author

Marked status:design since we need some sort of spec about how we will truncate the names.

@CharliePoole CharliePoole self-assigned this Mar 7, 2014
@jpierson
Copy link

jpierson commented Apr 1, 2014

We have run across this too when using data driven tests in combination with the Visual Studio adapter for NUnit. If I remember correctly I believe it caused an error in the adapter or in visual studio when these tests were run. Temporarily we modified our tests so that the data passed was a custom object that implemented ToString so that we could control how it appeared in Visual Studio. I would be nice to be forced into such workaround though.

@CharliePoole
Copy link
Contributor Author

On Launchpad, Dave Kipfer wrote:

When running repeated tests, the TestName is identical between
iterations. Adding an iteration number would be helpful to a listener
to distinguish one instance from another without counting them itself.

We should take this into account in the algorithm for name generation.

@CharliePoole CharliePoole modified the milestones: 3.0Beta1, 3.0 Oct 7, 2014
@CharliePoole CharliePoole removed their assignment Jan 3, 2015
@CharliePoole CharliePoole modified the milestones: 3.0Alpha5, 3.0Beta1 Jan 3, 2015
@CharliePoole
Copy link
Contributor Author

Started work on spec at https://github.com/nunit/dev/wiki/Generation-of-Test-Names

@CharliePoole CharliePoole self-assigned this Jan 22, 2015
@CharliePoole
Copy link
Contributor Author

Spec is now complete. Please review.

@CharliePoole
Copy link
Contributor Author

PR #469 is at least a partial fix to this problem. I'm postponing further action - if any is needed - until the beta.

@rprouse rprouse modified the milestones: 3.0Beta3, 3.0Beta2 May 7, 2015
@CharliePoole
Copy link
Contributor Author

@nunit/core-team Please review the updated spec at https://github.com/nunit/dev/wiki/Generation-of-Test-Names at a high priority.

If we can agree on the approach there, we can quickly close several outstanding issues. If you have read all the boilerplate before, you'll find the new proposal near the end of the page.

@CharliePoole
Copy link
Contributor Author

@nunit/core-team It has been a week and nobody has commented on the proposal for how to resolve this issue. Kindly let me know what you think so we can start implementing it.

@oznetmaster
Copy link
Contributor

The proposal seems quite reasonable to me.

@CharliePoole
Copy link
Contributor Author

Moving ahead on this as a feature, following the spec at least initially.

@CharliePoole
Copy link
Contributor Author

The spec at https://github.com/nunit/dev/wiki/Generation-of-Test-Names has been updated to reflect the current status and to remove all discussion about NUnit 2.x problems. It will become a technical note in the documentation when this issue is complete. @nunit/core-team and @nunit/contributors please let me know if you think I've missed something.

@rprouse
Copy link
Member

rprouse commented Oct 26, 2015

Fixed by #912

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants