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
Add support for ref bool
, ref bool?
, in bool
, and in bool?
when using NUnit.Framework.ValuesAttribute
#3872
Comments
I'm not against this change, but can you provide some use case for why a user would use
I don't think this is a design decision, but rather that the NUnit code is older than these concepts (or perhaps that nobody ever considered this case). I think the implementation should be more specific, so we only capture
I don't think this is possible (I'll have to examine this in more detail). The problem is that in these situations we don't create a test as there is no data for the test, so there is no place to associate the error. |
It's also worth mentioning that |
|
@lsolano In terms of design expressiveness, passing by value ( |
I'd be in favor either of making this just work or of producing an error for such methods. Introducing a new error seems unlikely to break anyone in practice because it's not likely that anyone has methods marked as test methods that have in/ref parameters, because of how NUnit behaves if you do that. Even if it did break some people (and I still think this is probably zero), we have treated things like this in the past as bug fixes. I.e. it should have been producing an error all along, and we consider it to be a bug that the current versions are missing this error. |
Me too, the current behavior (silently ignored test cases) is worse than having, or not, the support for reference types (normal or read-only ones). |
Thanks for noticing this. I agree the current behaviour of silently skipping tests isn't ideal, and I think any solution here should be generalized. [Test]
public void TestTheValues([Values(true, false)] in bool a)
{
Assert.That(true); // Passes
}
[Test]
public void TestTheValues([Values] in bool a)
{
Assert.That(true); // Never runs
} It may just be my mental model, but I think of |
@stevenaw It's the same for enumerations. |
@lsolano |
The following type of tests are not executed because they do not produce any data for
[Values]
attribute when parameters arein bool
,in bool?
,ref bool
, orref bool?
.The test is not reported as failure, or ignored but it is silently not executed.
If the described behavior is not a design decision I would like to add support for the four scenarios (already implemented on my fork at commit d6f38fadc1c790695720bddde233c4b0fcdb02f4).
As a side note, it will be very helpful to have some kind of warning about those situations.
The text was updated successfully, but these errors were encountered: