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

How to fail tests with name collisions #3893

Open
richard-fine opened this issue Jul 7, 2021 · 0 comments
Open

How to fail tests with name collisions #3893

richard-fine opened this issue Jul 7, 2021 · 0 comments
Labels

Comments

@richard-fine
Copy link
Contributor

We run NUnit tests as part of a larger infrastructure for testing - tracking test performance over time, monitoring test flakiness, etc.

A core assumption that we make is that the test's full name is an appropriate key to use for those systems. The key has to be stable over time (so I believe NUnit's own 'Id' attribute is not suitable), and should also be unique.

However, it's possible for a user to create a situation where two test cases both have identical full names. For non-parametric tests this can't easily happen, but with parametric tests or fixtures it can be done by e.g. accidentally duplicating a TestCase, or using TestCaseData.SetName incorrectly. The specific case that led me to open this issue was the latter, where the name that the developer was constructing for the tests failed to take one of the parameters into account, resulting in two tests with different parameters but identical names.

I can't see any reason why this usage should be supported, so I am wondering how I could block it from happening. Ideally, any name collisions between tests in a session should cause all colliding tests to fail/error. I'd like to do this within NUnit, rather than in postprocessing or a custom runner, so that launching tests through VS/Rider/etc shows the same behaviour.

So, in conclusion, my questions:

  1. Is there any way to do this using NUnit's existing extensibility features? It seems tricky because the extensibility points are mostly set up around the context of a single test, but checking for collisions requires knowledge of multiple tests.
  2. If not, is this something that perhaps NUnit should support out of the box?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants