Skip to content

Commit ca20039

Browse files
committed
Use AssertionScope to always include response.DebugInformation in the response body Should() assertions. This changes the way assertions are executed though, reporting on all ALL the failures. Since we do quite a few assertions in a single method this would become noisy so we hack the message to only include the first failure as before (#3408)
(cherry picked from commit df95930)
1 parent db3da7b commit ca20039

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Tests/Tests/Framework/EndpointTests/ApiIntegrationTestBase.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Elastic.Managed.Ephemeral;
77
using Elasticsearch.Net;
88
using FluentAssertions;
9+
using FluentAssertions.Execution;
910
using Nest;
1011
using Tests.Core.Client;
1112
using Tests.Core.Extensions;
@@ -54,7 +55,20 @@ protected override Task AssertOnAllResponses(Action<TResponse> assert)
5455
return;
5556
}
5657

57-
assert(r);
58+
using (var scope = new AssertionScope())
59+
{
60+
assert(r);
61+
var failures = scope.Discard();
62+
if (failures.Length <= 0) return;
63+
64+
var failure = failures[0];
65+
scope.AddReportable("Failure", failure);
66+
scope.AddReportable("DebugInformation", r.DebugInformation);
67+
scope.FailWith( $@"{{Failure}}
68+
Response Under Test:
69+
{{DebugInformation}}");
70+
71+
}
5872
});
5973
}
6074

0 commit comments

Comments
 (0)