From 03d1f984024c31c1329a7aedb77184e576fcccce Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Sat, 18 Apr 2020 19:33:53 +0200 Subject: [PATCH] Improve AssertLinkNotDead test output in case of exception If the test fails with an exception other than the `EqualException` the failed URL isn't logged. This general exception handler takes care of e.g. `HttpRequestException` and reports the URL that failed to be checked. Stumbled upon this while checking why [this test run](https://app.circleci.com/pipelines/github/btcpayserver/btcpayserver/2934/workflows/0525d9fd-e4de-49dc-957b-d98b16a9abd4/jobs/7199/parallel-runs/0/steps/0-102) fails. --- BTCPayServer.Tests/UnitTest1.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 96c51a92f..1fb0349d2 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -158,9 +158,11 @@ namespace BTCPayServer.Tests Assert.Equal(HttpStatusCode.OK, (await httpClient.SendAsync(request)).StatusCode); Logs.Tester.LogInformation($"OK: {url} ({file})"); } - catch (EqualException ex) + catch (Exception ex) { - Logs.Tester.LogInformation($"FAILED: {url} ({file}) {ex.Actual}"); + var details = ex is EqualException ? (ex as EqualException).Actual : ex.Message; + Logs.Tester.LogInformation($"FAILED: {url} ({file}) {details}"); + throw; } }