protected override void InvokeStepSingleTime(bool forceInvoke) { // 重置计时时间 Actuator.ResetTiming(); // 调用前置监听 OnPreListener(); this.Result = StepResult.NotAvailable; this.Result = Actuator.InvokeStep(forceInvoke); // 如果当前step被标记为记录状态,则返回状态信息 if (null != StepData && StepData.RecordStatus) { RecordRuntimeStatus(); } // 调用后置监听 OnPostListener(); if (null != StepData && StepData.HasSubSteps) { StepTaskEntityBase subStepEntity = SubStepRoot; do { if (!forceInvoke && Context.Cancellation.IsCancellationRequested) { this.Result = StepResult.Abort; return; } subStepEntity.Invoke(forceInvoke); } while (null != (subStepEntity = subStepEntity.NextStep)); } }
protected override void InvokeStepSingleTime(bool forceInvoke) { // 重置计时 Actuator.ResetTiming(); // 调用前置监听 OnPreListener(); // 开始计时 Actuator.StartTiming(); // 停止计时 Actuator.EndTiming(); // 应为TryFinally块上级为空,默认为pass this.Result = StepResult.Pass; // 调用后置监听 OnPostListener(); StepTaskEntityBase tryBlock = SubStepRoot; StepTaskEntityBase finallyBlock = tryBlock.NextStep; try { tryBlock.Invoke(forceInvoke); } finally { // finally模块是强制调用 finallyBlock.Invoke(true); } if (null != StepData && StepData.RecordStatus) { RecordRuntimeStatus(); } }
protected override void InvokeStepSingleTime(bool forceInvoke) { // 重置计时时间 Actuator.ResetTiming(); // 调用前置监听 OnPreListener(); this.Result = StepResult.NotAvailable; this.Result = Actuator.InvokeStep(forceInvoke); // 如果当前step被标记为记录状态,则返回状态信息 if (null != StepData && StepData.RecordStatus) { RecordRuntimeStatus(); } // 调用后置监听 OnPostListener(); object returnValue = Actuator.Return; // 如果执行结果不是bool类型或者为False,或者没有下级节点,则退出当前循环 bool conditionFail = !(returnValue is bool) || !(bool)returnValue; if (conditionFail || null == StepData || !StepData.HasSubSteps) { return; } // 执行下级的所有Step StepTaskEntityBase subStepEntity = SubStepRoot; do { if (!forceInvoke && Context.Cancellation.IsCancellationRequested) { this.Result = StepResult.Abort; return; } subStepEntity.Invoke(forceInvoke); } while (null != (subStepEntity = subStepEntity.NextStep)); }
// protected override void CheckSequenceData() // { // if (null != StepData.Function) // { // Context.LogSession.Print(LogLevel.Error, Context.SessionId, // $"Conditionblock cannot configure function data. Step:{StepData.Name}"); // I18N i18N = I18N.GetInstance(Constants.I18nName); // throw new TestflowDataException(ModuleErrorCode.SequenceDataError, i18N.GetStr("ConditionBlockHasFunc")); // // } // if (null != StepData.SubSteps && // StepData.SubSteps.Any(item => item.StepType != SequenceStepType.ConditionStatement)) // { // Context.LogSession.Print(LogLevel.Error, Context.SessionId, // $"Some steps under condition block is not ConditionStatement type. Step:{GetStack()}"); // I18N i18N = I18N.GetInstance(Constants.I18nName); // throw new TestflowDataException(ModuleErrorCode.SequenceDataError, i18N.GetStr("IllegalStepType")); // } // } protected override void InvokeStepSingleTime(bool forceInvoke) { // 重置计时时间 Actuator.ResetTiming(); // 调用前置监听 OnPreListener(); // 开始计时 Actuator.StartTiming(); // 停止计时 Actuator.EndTiming(); this.Result = StepResult.Pass; // 如果当前step被标记为记录状态,则返回状态信息 if (null != StepData && StepData.RecordStatus) { RecordRuntimeStatus(); } // 调用后置监听 OnPostListener(); if (null != StepData && StepData.HasSubSteps) { StepTaskEntityBase subStepEntity = SubStepRoot; do { subStepEntity.Invoke(forceInvoke); object returnValue = subStepEntity.Return; // 如果ConditionStatement返回值为True则说明该分支已执行完成,则跳过后续的Step if (returnValue is bool && (bool)returnValue) { break; } } while (null != (subStepEntity = subStepEntity.NextStep)); } }
protected override void InvokeStepSingleTime(bool forceInvoke) { int index = 0; while (true) { try { while (true) { // 设置循环变量的值 if (null != _loopVariable) { Context.VariableMapper.SetParamValue(_loopVariable, StepData.LoopCounter.CounterVariable, index++); } // 如果是取消状态并且不是强制执行则返回。因为ConditionLoop内部有循环,所以需要在内部也做判断 if (!forceInvoke && Context.Cancellation.IsCancellationRequested) { BreakAndReportAbortMessage(); } // 重置计时时间 Actuator.ResetTiming(); // 调用前置监听 OnPreListener(); this.Result = StepResult.NotAvailable; this.Result = Actuator.InvokeStep(forceInvoke); // 如果当前step被标记为记录状态,则返回状态信息 if (null != StepData && StepData.RecordStatus) { RecordRuntimeStatus(); } // 调用后置监听 OnPostListener(); // 如果执行结果不是bool类型或者为False,或者没有下级节点,则退出当前循环 object returnValue = Actuator.Return; bool conditionFail = !(returnValue is bool) || !(bool)returnValue; if (conditionFail || null == StepData || !StepData.HasSubSteps) { return; } // 执行所有的下级Step StepTaskEntityBase subStepEntity = SubStepRoot; do { if (!forceInvoke && Context.Cancellation.IsCancellationRequested) { this.Result = StepResult.Abort; return; } subStepEntity.Invoke(forceInvoke); } while (null != (subStepEntity = subStepEntity.NextStep)); } } catch (TestflowLoopBreakException ex) { ex.CalcDown(); // 如果计数大于0,则继续抛出到上层 if (ex.Count > 0) { throw; } // 如果是跳出当前循环,则return if (ex.BreakLoop) { return; } } } }