-
Notifications
You must be signed in to change notification settings - Fork 32
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
Nunit1007 - ignore [Test] attribute when [TestCaseSource] is present #212
Comments
I think you are right regarding ignoring the |
@mikkelbu I completely agree with your reasoning that Furthermore, I want to hint that the same reasing applies to the What I would not like to have is a Warning message about cases where both attributes are specified. From nunits point of view it is perfectly fine to have them both specified, so IMHO nothing which warants warning. Maybe an Info message, but even that I would probably deactivate, considering that the codebase (very large codebase, hundreds of developers) I am working with have these redundant occurences on tests in the range of several thousands. It is still a small fraction on the overall test number, but nevertheless a huge code churn for just stylistic changes. |
@siprbaum that was my initial reaction as well. From Nunit's perspective there is nothing wrong with supplying both, it's just unnecessary. So in my opinion both |
Thanks for the feedback and the initial report. You are both right that it should be an optional diagnostic (with Info level). Then the user can activate it locally - and also tweak the severity so it fits their setup. |
Consider the following sample:
The above code generates the following error:
NUnit1007 "Method has non-void return type 'bool', but no result is expected in ExpectedResult"
Problem
But this is a false positive in this scenario. The
ExpectedResult
is actually provided through theTestCaseSource
but the analyzer only looks at the[Test]
attribute.Possible solution
The NUnit1007 analyzer could just ignore the
[Test]
attribute when a[TestCaseSource]
is present.An alternative would be to raise an error when you add both
[Test]
and[TestCaseSource]
but that seems overly restrictive because there's nothing really wrong with it (as I see it).The text was updated successfully, but these errors were encountered: