You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the new custom strategy logic (introduced on PR1904) so I can take a screenshot on test failure however when I have implemented this it is only asserting on the first assert and not reporting any additional asserts.
Complete minimal example reproducing the issue
Here is a custom strategy which is just a copy of CollectingAssertionStrategy to demonstrate the issue.
publicclassCustomAssertionStrategy:IAssertionStrategy{privatereadonlyList<string>failureMessages=newList<string>();/// <summary>/// Returns the messages for the assertion failures that happened until now./// </summary>publicIEnumerable<string> FailureMessages => failureMessages;/// <summary>/// Discards and returns the failure messages that happened up to now./// </summary>publicIEnumerable<string>DiscardFailures(){vardiscardedFailures= failureMessages.ToArray();
failureMessages.Clear();returndiscardedFailures;}/// <summary>/// Will throw a combined exception for any failures have been collected since <see cref="StartCollecting"/> was called./// </summary>publicvoidThrowIfAny(IDictionary<string,object>context){if(failureMessages.Any()){varbuilder=new StringBuilder();
builder.AppendLine(string.Join(Environment.NewLine, failureMessages));if(context.Any()){foreach(KeyValuePair<string,object> pair in context){
builder.AppendFormat("\nWith {0}:\n{1}", pair.Key, pair.Value);}}
Services.ThrowException(builder.ToString());}}/// <summary>/// Instructs the strategy to handle a assertion failure./// </summary>publicvoidHandleFailure(stringmessage){
failureMessages.Add(message);}}
Description
Hi,
I am trying to use the new custom strategy logic (introduced on PR1904) so I can take a screenshot on test failure however when I have implemented this it is only asserting on the first assert and not reporting any additional asserts.
Complete minimal example reproducing the issue
Here is a custom strategy which is just a copy of CollectingAssertionStrategy to demonstrate the issue.
and then
Expected behavior:
Both assertion failures should be reported when using a custom strategy
Actual behavior:
Only the first assertion failure is reported
Versions
5.8.0, .Net Framework 4.7.1
Additional Information
See https://github.com/tomaustin700/FluentAssertionIssue for a full solution demonstrating this issue.
The text was updated successfully, but these errors were encountered: