From d83533372ba3bd1c06348e8c5589219033db73d9 Mon Sep 17 00:00:00 2001 From: Kim Ju Young Date: Fri, 2 May 2025 14:44:31 +0900 Subject: [PATCH] Improve ExpectNextNAsync error message clarity Previous error messages were unclear when ExpectNextNAsync failed, especially in tests (e.g., with Kafka). The new message includes the exact index of the mismatch and shows both expected and actual values. Old: "Expected one of (1, 2, 3, ...), but got '5'" New: "Expected element at index 24 to be '25', but got '5'" This improves debugging clarity for stream-based tests. --- .../Akka.Streams.TestKit/TestSubscriber_Shared.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs b/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs index fb3938bf6dc..e73d9e5ca05 100644 --- a/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs +++ b/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs @@ -91,11 +91,19 @@ internal static async Task ExpectNextNTask( CancellationToken cancellationToken) { var list = all.ToList(); + int index = 0; foreach (var x in list) + { await probe.ExpectMsgAsync>( - assert: y => AssertEquals(y.Element, x, "Expected one of ({0}), but got '{1}'", string.Join(", ", list), y.Element), - timeout: timeout, + assert: y => AssertEquals( + y.Element, + x, + "Expected element at index {0} to be '{1}', but got '{2}'", + index, x, y.Element), + timeout: timeout, cancellationToken: cancellationToken); + index++; + } } internal static async Task ExpectNextUnorderedNTask(