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

Rule to check users don't accidentally specify CallerArgumentExpression parameters #639

Closed
manfred-brands opened this issue Nov 14, 2023 · 0 comments · Fixed by #641
Closed
Assignees

Comments

@manfred-brands
Copy link
Member

To improve messages for failing tests, NUnit4 uses CallerMemberExpresion to convert the actual and constraint parameters into text.

Users used to the old format spec, might accidentally pass in two paramters without realizing that this doesn't work.

Assert.That(actual, Is.EqualTo(expected), "Expected {0}, but got {1}", expected, actual);

In NUnit 4, this should have been specified as:

Assert.That(actual, Is.EqualTo(expected), $"Expected {expected}, but got {actual}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants