Better exception logging for tests with multiple time-moments.

This commit is contained in:
benbierens 2023-08-30 10:13:48 +02:00
parent a1ec187919
commit 8d7a7b4d1b
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
1 changed files with 15 additions and 4 deletions

View File

@ -126,10 +126,11 @@ namespace ContinuousTests
private void ThrowFailTest() private void ThrowFailTest()
{ {
var ex = UnpackException(exceptions.First()); var exs = UnpackExceptions(exceptions);
Log(ex.ToString()); var exceptionsMessage = GetCombinedExceptionsMessage(exs);
OverviewLog($" > Test failed {FuturesInfo()}: " + ex.Message); Log(exceptionsMessage);
throw ex; OverviewLog($" > Test failed {FuturesInfo()}: " + exceptionsMessage);
throw new Exception(exceptionsMessage);
} }
private string FuturesInfo() private string FuturesInfo()
@ -152,6 +153,16 @@ namespace ContinuousTests
} }
} }
private string GetCombinedExceptionsMessage(Exception[] exceptions)
{
return string.Join(Environment.NewLine, exceptions.Select(ex => ex.ToString()));
}
private Exception[] UnpackExceptions(List<Exception> exceptions)
{
return exceptions.Select(UnpackException).ToArray();
}
private Exception UnpackException(Exception exception) private Exception UnpackException(Exception exception)
{ {
if (exception is AggregateException a) if (exception is AggregateException a)