Example #1
0
        public static RuntimeState GetRuntimeState(FailedType failedType)
        {
            RuntimeState state;

            switch (failedType)
            {
            case FailedType.AssertionFailed:
            case FailedType.ForceFailed:
                state = RuntimeState.Failed;
                break;

            case FailedType.TestGenFailed:
            case FailedType.TargetError:
            case FailedType.SetUpFailed:
            case FailedType.RetryFailed:
            case FailedType.RuntimeError:
            case FailedType.TimeOut:
                state = RuntimeState.Error;
                break;

            case FailedType.Abort:
                state = RuntimeState.Abort;
                break;

            default:
                state = RuntimeState.Error;
                break;
            }
            return(state);
        }
Example #2
0
        public static StepResult GetStepResult(FailedType failedType)
        {
            StepResult result;

            switch (failedType)
            {
            case FailedType.AssertionFailed:
            case FailedType.ForceFailed:
                result = StepResult.Failed;
                break;

            case FailedType.TestGenFailed:
            case FailedType.TargetError:
            case FailedType.SetUpFailed:
            case FailedType.RetryFailed:
            case FailedType.RuntimeError:
                result = StepResult.Error;
                break;

            case FailedType.TimeOut:
                result = StepResult.Timeout;
                break;

            case FailedType.Abort:
                result = StepResult.Abort;
                break;

            default:
                result = StepResult.Error;
                break;
            }
            return(result);
        }
Example #3
0
 public void Reset()
 {
     _failedType = FailedType.None;
     _expectAddFailedCount = 0;
     _expectGetFailedCount = 0;
     _currentFailedCount = 0;
 }
Example #4
0
        public static StatusReportType GetReportType(FailedType failedType)
        {
            StatusReportType reportType;

            switch (failedType)
            {
            case FailedType.AssertionFailed:
            case FailedType.ForceFailed:
                reportType = StatusReportType.Failed;
                break;

            case FailedType.TestGenFailed:
            case FailedType.TargetError:
            case FailedType.SetUpFailed:
            case FailedType.RetryFailed:
            case FailedType.RuntimeError:
            case FailedType.TimeOut:
            case FailedType.Abort:
                reportType = StatusReportType.Error;
                break;

            default:
                reportType = StatusReportType.Error;
                break;
            }
            return(reportType);
        }
Example #5
0
 public void Reset()
 {
     _failedType           = FailedType.None;
     _expectAddFailedCount = 0;
     _expectGetFailedCount = 0;
     _currentFailedCount   = 0;
 }
Example #6
0
 public SequenceFailedInfo(string failedInfo, FailedType type)
 {
     Type               = type;
     this.Message       = failedInfo;
     this.Source        = string.Empty;
     this.StackTrace    = string.Empty;
     this.ExceptionType = string.Empty;
 }
Example #7
0
        public static string GetFailedStr(string message, FailedType failedType)
        {
            StringBuilder failedStr = new StringBuilder(400);

            return(failedStr.Append(failedType).Append(Delim).Append(message).Append(Delim)
                   .Append(string.Empty).Append(Delim).Append(string.Empty).Append(Delim)
                   .Append(string.Empty).Append(Delim).Append(0).ToString());
        }
Example #8
0
 public FailedInfo(string failedInfo, FailedType type)
 {
     Type               = type;
     this.Message       = failedInfo;
     this.Source        = string.Empty;
     this.StackTrace    = string.Empty;
     this.ExceptionType = string.Empty;
     this.ErrorCode     = 0;
 }
Example #9
0
        private void FillFinalExceptionReportInfo(Exception ex, out StatusReportType finalReportType,
                                                  out StepResult lastStepResult, out FailedInfo failedInfo)
        {
            if (ex is TaskFailedException)
            {
                TaskFailedException failedException = (TaskFailedException)ex;
                FailedType          failedType      = failedException.FailedType;
                this.State      = ModuleUtils.GetRuntimeState(failedType);
                finalReportType = ModuleUtils.GetReportType(failedType);
                lastStepResult  = ModuleUtils.GetStepResult(failedType);
                failedInfo      = new FailedInfo(ex, failedType);
                _context.LogSession.Print(LogLevel.Info, Index, "Step force failed.");
            }
            else if (ex is TestflowAssertException)
            {
                this.State      = RuntimeState.Failed;
                finalReportType = StatusReportType.Failed;
                lastStepResult  = StepResult.Failed;
                failedInfo      = new FailedInfo(ex, FailedType.AssertionFailed);
                _context.LogSession.Print(LogLevel.Error, Index, "Assert exception catched.");
            }
            else if (ex is ThreadAbortException)
            {
                this.State      = RuntimeState.Abort;
                finalReportType = StatusReportType.Error;
                lastStepResult  = StepResult.Abort;
                failedInfo      = new FailedInfo(ex, FailedType.Abort);
                _context.LogSession.Print(LogLevel.Warn, Index, $"Sequence {Index} execution aborted");
            }
            else if (ex is TestflowException)
            {
                this.State      = RuntimeState.Error;
                finalReportType = StatusReportType.Error;
                lastStepResult  = StepResult.Error;
                failedInfo      = new FailedInfo(ex, FailedType.RuntimeError);
                _context.LogSession.Print(LogLevel.Error, Index, ex, "Inner exception catched.");
            }
            else
            {
                this.State      = RuntimeState.Error;
                finalReportType = StatusReportType.Error;
                lastStepResult  = StepResult.Error;
                failedInfo      = new FailedInfo(ex, FailedType.RuntimeError);
                _context.LogSession.Print(LogLevel.Error, Index, ex, "Runtime exception catched.");
            }
//            else if (ex is TargetInvocationException)
//            {
//                this.State = RuntimeState.Failed;
//                finalReportType = StatusReportType.Failed;
//                lastStepResult = StepResult.Failed;
//                failedInfo = new FailedInfo(ex.InnerException, FailedType.TargetError);
//                _context.LogSession.Print(LogLevel.Error, Index, ex, "Invocation exception catched.");
//            }
        }
Example #10
0
        private void RecordInvocationError(Exception ex, FailedType failedType)
        {
            FailedInfo         failedInfo = new FailedInfo(ex, failedType);
            SequenceStatusInfo statusInfo = new SequenceStatusInfo(SequenceIndex, this.GetStack(), StatusReportType.Record, RuntimeState.Running, Result, failedInfo)
            {
                ExecutionTime = Actuator.ExecutionTime, ExecutionTicks = Actuator.ExecutionTicks, CoroutineId = this.Coroutine.Id, WatchDatas = Context.VariableMapper.GetKeyVariablesValues(StepData)
            };

            // 一旦失败,需要记录WatchData
            Context.StatusQueue.Enqueue(statusInfo);
            Context.LogSession.Print(LogLevel.Error, Context.SessionId, ex.Message);
        }
Example #11
0
        public static string GetFailedStr(Exception exception, FailedType failedType, string errorCodeProperty)
        {
            StringBuilder failedStr  = new StringBuilder(400);
            string        stackTrace = exception.StackTrace;

            if (!string.IsNullOrWhiteSpace(stackTrace) && stackTrace.Contains("'"))
            {
                stackTrace = stackTrace.Replace("'", "*");
            }
            return(failedStr.Append(failedType).Append(Delim).Append(exception.Message).Append(Delim)
                   .Append(exception.Source).Append(Delim).Append(stackTrace).Append(Delim)
                   .Append(exception.GetType().Name).Append(Delim).Append(exception.HResult).ToString());
        }
Example #12
0
 //------------------------------------------------------------------------------------------
 // オブジェクトを起動する
 //------------------------------------------------------------------------------------------
 public void EnableFrame(FailedType type)
 {
     enableFrame          = true;
     failedCanvas.enabled = true;
     waitTime             = FailedFrame.FADE_TIME;
     this.type            = type;
     if (type == FailedType.TimeUp)
     {
         typeText.text = "Time Up";
     }
     else if (type == FailedType.Fall)
     {
         typeText.text = "Fall";
     }
 }
Example #13
0
        public FailedInfo(Exception exception, FailedType failedType)
        {
            this.Message = exception.Message;
            this.Type    = failedType;
            this.Source  = exception.Source;
            string stackTrace = exception.StackTrace;

            if (!string.IsNullOrWhiteSpace(stackTrace) && stackTrace.Contains("'"))
            {
                stackTrace = stackTrace.Replace("'", "*");
            }
            this.StackTrace = stackTrace;
            Type exceptionType = typeof(Exception);

            this.ExceptionType = $"{exceptionType.Namespace}.{exceptionType.Name}";
            this.ErrorCode     = exception.HResult;
        }
Example #14
0
 public void SetExpectFailedCount(FailedType failedType, int count)
 {
     _failedType        = failedType;
     _expectFailedCount = count;
 }
Example #15
0
 public RequestFailed(FailedType type)
 {
     FailedType = type;
 }
Example #16
0
 // 执行step,即使失败也继续执行,如果失败,写入runtimeStatus
 private void InvokeStepAndForceContinue(bool forceInvoke)
 {
     try
     {
         InvokeStepSingleTime(forceInvoke);
     }
     catch (TaskFailedException ex)
     {
         // 如果该失败类型不能被处理,则直接抛出
         if (!ModuleUtils.IsErrorCanBeHandled(ex.FailedType))
         {
             throw;
         }
         // 停止计时
         Actuator.EndTiming();
         this.Result = _isUnderRetryStep ? StepResult.RetryFailed : StepResult.Failed;
         RecordInvocationError(ex, ex.FailedType);
         HandleException(StepData.InvokeErrorAction, ex);
     }
     catch (TestflowAssertException ex)
     {
         // 停止计时
         Actuator.EndTiming();
         this.Result = _isUnderRetryStep ? StepResult.RetryFailed : StepResult.Failed;
         RecordInvocationError(ex, FailedType.AssertionFailed);
         HandleException(StepData.AssertFailedAction, ex);
     }
     catch (TargetInvocationException ex)
     {
         // 停止计时
         Actuator.EndTiming();
         RecordTargetInvocationError(ex);
         FailedAction failedAction = ex.InnerException is TestflowAssertException
             ? StepData.AssertFailedAction
             : StepData.InvokeErrorAction;
         HandleException(failedAction, ex.InnerException);
     }
     catch (TestflowLoopBreakException ex)
     {
         // 停止计时
         Actuator.EndTiming();
         if (null != ex.InnerException)
         {
             FailedType failedType = GetFailedType(ex.InnerException);
             RecordInvocationError(ex, failedType);
             HandleException(StepData.AssertFailedAction, ex);
         }
         else
         {
             throw;
         }
     }
     catch (TargetException ex)
     {
         // 停止计时
         Actuator.EndTiming();
         this.Result = StepResult.Error;
         RecordInvocationError(ex, FailedType.TargetError);
         HandleException(StepData.InvokeErrorAction, ex);
     }
 }
Example #17
0
 public void SetExpectFailedCount(FailedType failedType, int count)
 {
     _failedType = failedType;
     _expectGetFailedCount = count;
     _expectUpdateFailedCount = count;
 }
Example #18
0
 public static bool IsErrorCanBeHandled(FailedType failedType)
 {
     return(failedType == FailedType.AssertionFailed || failedType == FailedType.ForceFailed ||
            failedType == FailedType.TargetError ||
            failedType == FailedType.RetryFailed);
 }
Example #19
0
        public RequestFailed(FailedType type) {

            FailedType = type;
        }
Example #20
0
 public void SetExpectAddFailedCount(FailedType failedType, int count)
 {
     _failedType = failedType;
     _expectAddFailedCount = count;
 }
Example #21
0
 public TaskFailedException(int sequenceIndex, FailedType failedType) : base($"Sequence {0} failed.")
 {
     this.SequenceIndex = sequenceIndex;
     this.FailedType    = failedType;
 }
Example #22
0
 public RequestFailed(Exception e, FailedType type)
 {
     ExceptionObject = e;
     FailedType      = type;
 }
Example #23
0
 public TaskFailedException(int sequenceIndex, string message, FailedType failedType) : base(message)
 {
     this.SequenceIndex = sequenceIndex;
     this.FailedType    = failedType;
 }