Beispiel #1
0
        internal (Status StepStatus, Exception ThrowedEx, bool NeedRethrow) ProceedException(Exception e, Status defaultStepStatus = Status.failed)
        {
            var       throwEx    = true;
            var       stepStatus = defaultStepStatus;
            Exception throwedEx;

            if (e is TargetInvocationException)
            {
                throwedEx = AllureLifecycle.GetInnerExceptions(e)
                            .First(q => q.GetType() != typeof(TargetInvocationException));
            }
            else
            {
                throwedEx = e;
            }

            if (throwedEx is InconclusiveException)
            {
                stepStatus = Status.skipped;
            }

            else if (throwedEx is SuccessException)
            {
                throwEx = false; // no throw ex, because assert.pass
            }
            var list =
                TestContext.CurrentContext.Test.Properties.Get(AllureConstants.TestAsserts) as List <Exception>;

            list?.Add(throwedEx);
            if (!throwedEx.Data.Contains(Rethrow))
            {
                throwedEx.Data.Add(Rethrow, true);
                AllureLifecycle.Instance.MakeStepWithExMessage(_assertsInTestBeforeStep.Count, _stepText, throwedEx,
                                                               defaultStepStatus);
                AllureLifecycle.CurrentTestActionsInException?.ForEach(action => action.Invoke());
                AllureLifecycle.GlobalActionsInException?.ForEach(action => action.Invoke());
            }

            return(stepStatus, throwedEx, throwEx);
        }