From 1141a2dafe65a4094c9ec672a1561c2c643f85b1 Mon Sep 17 00:00:00 2001 From: Ayoub Kaanich Date: Sat, 22 Feb 2020 22:50:07 +0100 Subject: [PATCH] Don't throw in tear down if test already failing --- Test/TestHelper.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Test/TestHelper.cs b/Test/TestHelper.cs index 1219193f..4b6989bd 100644 --- a/Test/TestHelper.cs +++ b/Test/TestHelper.cs @@ -9,6 +9,7 @@ using System.Reflection; using System.Threading; using NUnit.Framework; +using NUnit.Framework.Interfaces; namespace Test { @@ -113,9 +114,13 @@ internal static void ConfirmIdleState() var isStarted = d.Started; if (isStarted) d.StopCapture(); if (isOpened) d.Close(); - - Assert.IsFalse(isOpened, "Expected device to not to be Opened"); - Assert.IsFalse(isStarted, "Expected device to not be Started"); + var status = TestContext.CurrentContext.Result.Outcome.Status; + // If test already failed, no point asserting here + if (status != TestStatus.Failed) + { + Assert.IsFalse(isOpened, "Expected device to not to be Opened"); + Assert.IsFalse(isStarted, "Expected device to not be Started"); + } } } }