diff --git a/Allure.SpecFlowPlugin/AllureBindingInvoker.cs b/Allure.SpecFlowPlugin/AllureBindingInvoker.cs index 49c3a80f..635c4ef4 100644 --- a/Allure.SpecFlowPlugin/AllureBindingInvoker.cs +++ b/Allure.SpecFlowPlugin/AllureBindingInvoker.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Specialized; +using System.IO; using Allure.Net.Commons; using Allure.SpecFlowPlugin.SelectiveRun; using TechTalk.SpecFlow; @@ -43,7 +44,8 @@ IUnitTestRuntimeProvider unitTestRuntimeProvider { this.testRunnerManager = testRunnerManager; AllureSpecFlowPatcher.EnsureTestPlanSupportInjected( - unitTestRuntimeProvider + unitTestRuntimeProvider, + WriteErrorToFileSafe ); } @@ -75,6 +77,15 @@ out duration ); } + static void WriteErrorToFileSafe(Exception e) + { + try + { + File.WriteAllText(".allure_patch_error", e.ToString()); + } + catch (Exception) { } + } + (object, TimeSpan) ProcessHook( IBinding binding, IContextManager contextManager, diff --git a/Allure.SpecFlowPlugin/SelectiveRun/AllureSpecFlowPatcher.cs b/Allure.SpecFlowPlugin/SelectiveRun/AllureSpecFlowPatcher.cs index 098ead92..507729d4 100644 --- a/Allure.SpecFlowPlugin/SelectiveRun/AllureSpecFlowPatcher.cs +++ b/Allure.SpecFlowPlugin/SelectiveRun/AllureSpecFlowPatcher.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -13,7 +14,8 @@ static class AllureSpecFlowPatcher static bool isTestPlanSupportInjected= false; internal static void EnsureTestPlanSupportInjected( - IUnitTestRuntimeProvider unitTestRuntimeProvider + IUnitTestRuntimeProvider unitTestRuntimeProvider, + Action logError ) { if (isTestPlanSupportInjected) @@ -21,7 +23,14 @@ IUnitTestRuntimeProvider unitTestRuntimeProvider return; } - InjectTestPlanSupport(unitTestRuntimeProvider); + try + { + InjectTestPlanSupport(unitTestRuntimeProvider); + } + catch (Exception e) + { + logError(e); + } isTestPlanSupportInjected = true; }