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
Assert.Multiple has no message parameter #4547
Comments
Thanks for your thorough proposal @jmartschinke I've tried reviewing the original issue to understand some of the design decisions there but I can't see a clear description why there is no existing I understand this feature would bring clarity for your case but I'm a little concerned it could cause confusion for others. Elsewhere in the framework the That said, I think it's a nifty idea to be able to track and report on extra "context" within the test like this if we could generalize it 🙂 For a more immediate solution for you, if the intent is to write this as part of the test result, have you taken a look at using TestContext.WriteLine ? I haven't tested the below code but I'm curious if it works for you: for (var i = 0; i < count; i++)
{
TestContext.WriteLine($"iteration {i}");
Assert.Multiple(() => {
// Your asserts here
});
} |
Thank you for your help, this is indeed very helpful to know!
|
Interesting. Can you show (e.g. some screenshots) how this looks in the Visual Studio Test Explorer and in dotnet test ? |
Very low level question: Where did you implement your helper method? Did you extend anything? If so, what? I see the method but not the helper class :) |
I just added a static class named Asserts, so i can write Asserts.Multiple (instead of Assert.Multiple) to avoid name issues. |
Imagine the following example:
Often times you want to check a block of assertions at different times like in this example.
When you run this code, you get something like the following:
Now you cannot distinguish in which iteration the Assert.Multiple failed. What you would need to do is to write something like
Which would work, but you have to repeat at every assertion instead of writing it only once to the Assert.Multiple. You get the following output:
It would be better if you can write the code like this:
And then get this output:
The text was updated successfully, but these errors were encountered: