public async Task Execute(IStepBinding stepBinding, IServiceProvider serviceProvider, Collection <TestResultMessage> messages, TestRunContext testRunContext) { var attempts = 0; do { attempts++; try { await stepBinding .Execute(serviceProvider, messages) .ConfigureAwait(false); break; } catch (Exception exception) { if (IsTerminal(exception, attempts, testRunContext)) { throw; } } messages.Add( new TestResultMessage( TestResultMessage.StandardOutCategory, $"{StepsExecutor.StepLogIndent}Failed at {DateTime.UtcNow:o}, waiting and trying again{Environment.NewLine}")); await Task .Delay(testRunContext.EventualSuccess.DelayBetweenAttempts) .ConfigureAwait(false); } while (true); }
public async Task Execute(IStepBinding stepBinding, IServiceProvider serviceProvider, Collection <TestResultMessage> messages, TestRunContext testRunContext) { var attempts = 0; do { attempts++; await stepBinding .Execute(serviceProvider, messages) .ConfigureAwait(false); if (attempts >= testRunContext.EventualSuccess.MaximumAttempts) { break; } messages.Add( new TestResultMessage( TestResultMessage.StandardOutCategory, $"{StepsExecutor.StepLogIndent}Passed at {DateTime.UtcNow:o}, waiting and checking again{Environment.NewLine}")); await Task .Delay(testRunContext.EventualSuccess.DelayBetweenAttempts) .ConfigureAwait(false); } while (true); }
public static IStepExecutionStrategy GetFor(IStepBinding binding) { if (binding.IsSuccessEventual) { return(eventuallySuccesfulStepStrategy); } if (binding.IsMarkedMustNotEventuallyFail) { return(mustNotEventuallyFailStepStrategy); } return(executeOnceStepStrategy); }
public Task Execute(IStepBinding stepBinding, IServiceProvider serviceProvider, Collection <TestResultMessage> messages, TestRunContext testRunContext) => stepBinding .Execute(serviceProvider, messages);