internal static TResult StepRunner <TResult>(string stepName, Delegate del, bool throwEx, Status stepStatusIfFailed, params object[] stepParams) { var stepStatus = Status.passed; Exception throwedEx = null; var stepHelper = new StepHelper(stepName); var resultFunc = default(TResult); var uuid = $"{Guid.NewGuid():N}"; var stepResult = new StepResult { name = stepName, start = ToUnixTimestamp(DateTimeOffset.Now) }; Instance.StartStep(uuid, stepResult); ReportHelper.AddStepParameters(stepParams, uuid); try { switch (del) { case Action action when resultFunc is bool: action.Invoke(); resultFunc = (TResult)(object)true; break; case Func <TResult> func: resultFunc = func.Invoke(); break; default: resultFunc = (TResult)del.DynamicInvoke(); break; } stepStatus = stepHelper.GetStepStatus(); } catch (Exception e) { bool needRethrow; (stepStatus, throwedEx, needRethrow) = stepHelper.ProceedException(e, stepStatusIfFailed); if (throwEx) { throwEx = needRethrow; } } finally { Instance.UpdateStep(step => step.status = stepStatus); Instance.StopStep(uuid); } if (throwEx && throwedEx != null) { ExceptionDispatchInfo.Capture(throwedEx).Throw(); } return(resultFunc); }
public void BeforeStep() { var args = _scenarioContext?.StepContext?.StepInfo?.BindingMatch?.Arguments; if (args != null && args.Length > 0) { ReportHelper.AddStepParameters(args); } }
public override void OnEnter(MethodBase method, Dictionary <string, object> parameters) { if (string.IsNullOrEmpty(StepText)) { StepText = method.Name; } else { ConvertParameters(parameters); } AllureLifecycle.Instance.StartStep(StepText, StepUuid); if (parameters != null && parameters.Count > 0) { ReportHelper.AddStepParameters(parameters.Select(o => o.Value).ToArray(), StepUuid); } }