using OpenTap; using System; namespace AddInPlugin { [Display("Else", Group: "流程控制", Order: 0)] [AllowAnyChild] public class ElseStep : TestStep { public ElseStep() : base() { Rules.Add(() => this.GetPreviousStep() is ConditionBase, "必须在If/ElseIf之后", Name); } public override void PrePlanRun() { } public override void Run() { try { var previous = this.GetPreviousStep(); if (!(previous is ConditionBase cb)) { throw new Exception("Error Stucture"); } if (cb.ConditionResult != true) { RunChildSteps(); } else { UpgradeVerdict(Verdict.NotSet); } } catch (Exception ex) { Log.Error("Else Run error. {0}", ex); UpgradeVerdict(Verdict.Error); } } public override void PostPlanRun() { } } }