-
Notifications
You must be signed in to change notification settings - Fork 33
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
Inconsistency among NUnit2045 "Call independent Assert statements..." vs. NUnit documentation that does not require "independent" #732
Comments
The indepedent is meant for situations like: Assert.That(instance, Is.Not.Null);
Assert.That(instance.Property1, Is.EqualTo(expectedProperty1));
Assert.That(instance.Property2, Is.EqualTo(expectedProperty2)); The analyzer suggests: Assert.That(instance, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(instance.Property1, Is.EqualTo(expectedProperty1));
Assert.That(instance.Property2, Is.EqualTo(expectedProperty2));
}); The In your case, if the I think the NUnit documentation could be updated to highlight when to group statements. The analyzer doesn't know what your class does, but it could be updated to assume that a method call might modify state and not suggest a grouping, unless the method is marked with a |
This sounds very reasonable. The majority of functions modifies some sort of state, and for all others |
Attributing code with |
Consider this piece of test code where
rate = new Rate(interval, window)
:The analyzer (version 3.10 with NUnit 3.14.0) issues "warning NUnit2045: Call independent Assert statements from inside an Assert.Multiple". This statement is not fully correct,...
Notes:
Update()
method calculatesValue
and returnstrue
ifValue
has changed.Assert.Multiple()
passes:Potential solutions:
Assert.Multiple()
with the NUnit team.The text was updated successfully, but these errors were encountered: