public void AfterScenario() { if (CurrentScenario != null) { var request = new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = Status }; var eventArg = new TestItemFinishedEventArgs(Bridge.Service, request, CurrentScenario); if (BeforeScenarioFinished != null) { BeforeScenarioFinished(this, eventArg); } if (!eventArg.Canceled) { CurrentScenario.Finish(request); if (AfterScenarioFinished != null) { AfterScenarioFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, CurrentScenario)); } CurrentScenarioDescription = string.Empty; } } }
public void TraceBindingError(BindingException ex) { if (CurrentScenario != null) { Status = Status.Failed; var request = new FinishTestItemRequest { Status = Status.Failed, EndTime = DateTime.UtcNow.AddMilliseconds(1), Issue = new Issue { Type = IssueType.AutomationBug, Comment = ex.Message } }; var errorRequest = new AddLogItemRequest { Level = LogLevel.Error, Time = DateTime.UtcNow.AddMilliseconds(1), Text = ex.ToString() }; CurrentScenario.Log(errorRequest); if (BeforeStepFinished != null) { BeforeStepFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, null)); } if (AfterStepFinished != null) { AfterStepFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, null)); } } }
protected override IEnumerable <ITestCommand> EnumerateTestCommands(IMethodInfo method) { if (method == null) { return(new[] { new ExceptionCommand(method, new ArgumentNullException("method")) }); } IEnumerable <ITestCommand> backgroundCommands; IEnumerable <ICommand> scenarioCommands; // NOTE: any exception must be wrapped in a command, otherwise the test runner will retry this method infinitely try { backgroundCommands = this.EnumerateBackgroundCommands(method).ToArray(); scenarioCommands = this.EnumerateScenarioCommands(method).ToArray(); } catch (Exception ex) { return(new[] { new ExceptionCommand(method, ex) }); } // NOTE: this is not in the try catch since we are yielding internally // TODO: address this - see http://stackoverflow.com/a/346772/49241 return(scenarioCommands.SelectMany( scenarioCommand => CurrentScenario.ExtractCommands(scenarioCommand.MethodCall, backgroundCommands.Concat(new[] { scenarioCommand })))); }
public override object VisitExpressionReference(ShapPangParser.ExpressionReferenceContext context) { IValue val = CurrentScenario.ResolveReference(context.ID().GetText(), ParsingContext.ElementScope.ElementName); string temp = val.GetType().ToString(); switch (val.GetType().ToString()) { case "ShapPang.Classes.Given": Given giv = (Given)val; if (giv.Description == null) { CurrentScenario.CurrentlyBuildingExplanation += " the given " + giv.Key + " (" + giv.Value.ToString() + ")"; } else { CurrentScenario.CurrentlyBuildingExplanation += giv.Description; } break; case "ShapPang.Classes.Derivative": Derivative div = (Derivative)val; CurrentScenario.CurrentlyBuildingExplanation += " the derivation of " + div.Name + " ("; if (div.Calculated == false) { div.CalculateDerivative(); } CurrentScenario.CurrentlyBuildingExplanation += " which equals " + div.Value.ToString() + ")"; break; } return(val.Value); }
protected override IEnumerable <ITestCommand> EnumerateTestCommands(IMethodInfo method) { if (method == null) { return(new[] { new ExceptionCommand(new MethodCall(null), new ArgumentNullException("method")) }); } IEnumerable <ITestCommand> backgroundCommands; IEnumerable <ICommand> scenarioCommands; // NOTE: any exception must be wrapped in a command, otherwise the test runner will retry this method infinitely try { backgroundCommands = this.EnumerateBackgroundCommands(method).ToArray(); scenarioCommands = this.EnumerateScenarioCommands(method).ToArray(); } catch (Exception ex) { return(new[] { new ExceptionCommand(new MethodCall(method), ex) }); } var continueOnFailureStepType = GetContinueOnFailureStepType(method); var omitArgumentsAttribute = GetCustomAttribute <OmitArgumentsFromScenarioNamesAttribute>(method); var omitArguments = omitArgumentsAttribute == null ? false : omitArgumentsAttribute.Enabled; // NOTE: this is not in the try catch since we are yielding internally // TODO: address this - see http://stackoverflow.com/a/346772/49241 return(scenarioCommands.SelectMany(c => CurrentScenario.ExtractCommands(c.MethodCall, backgroundCommands.Concat(new[] { c }), continueOnFailureStepType, omitArguments))); }
/// <summary> /// Immediately registers the <see cref="IDisposable"/> object for disposal after all steps in the current scenario have been executed. /// </summary> /// <typeparam name="T">The type of the object.</typeparam> /// <param name="obj">The object to be disposed.</param> /// <returns>The object.</returns> public static T Using <T>(this T obj) where T : IDisposable { if (obj != null) { CurrentScenario.AddTeardown(() => obj.Dispose()); } return(obj); }
public override object VisitAssign(ShapPangParser.AssignContext context) { if (context.ID().GetText() == CurrentDerivation.Name) { CurrentDerivation.Value = (decimal)base.VisitAssign(context); return(CurrentDerivation.Value); } IValue val = CurrentScenario.ResolveReference(context.ID().GetText(), ParsingContext.ElementScope.ElementName); return(base.VisitAssign(context)); }
public void TraceWarning(string text) { if (CurrentScenario != null) { var request = new AddLogItemRequest { Level = LogLevel.Warning, Time = DateTime.UtcNow.AddMilliseconds(1), Text = text }; CurrentScenario.Log(request); } }
public void TraceStep(StepInstance stepInstance, bool showAdditionalArguments) { if (CurrentScenario != null) { CurrentScenarioDescription += Environment.NewLine + stepInstance.Keyword + " " + stepInstance.Text; if (stepInstance.MultilineTextArgument != null) { CurrentScenarioDescription += Environment.NewLine + stepInstance.MultilineTextArgument; } var tableDescription = string.Empty; if (stepInstance.TableArgument != null) { tableDescription = string.Empty; foreach (var header in stepInstance.TableArgument.Header) { tableDescription += "| " + header + "\t"; } tableDescription += "|\n"; foreach (var row in stepInstance.TableArgument.Rows) { foreach (var value in row.Values) { tableDescription += "| " + value + "\t"; } tableDescription += "|\n"; } } if (!string.IsNullOrEmpty(tableDescription)) { CurrentScenarioDescription += Environment.NewLine + tableDescription; } var updateScenarioRequest = new UpdateTestItemRequest { Description = CurrentScenarioDescription }; CurrentScenario.Update(updateScenarioRequest); var stepInfoRequest = new AddLogItemRequest { Level = LogLevel.Info, //TODO log time should be greater than test time Time = DateTime.UtcNow.AddMilliseconds(1), Text = string.Format("{0}\r{1}", stepInstance.Keyword + " " + stepInstance.Text, tableDescription) }; CurrentScenario.Log(stepInfoRequest); } }
private string ScenarioNumber() { string currentScenario = CurrentScenario != null && CurrentScenario.Trim().Length > 0 ? CurrentScenario : ""; string scenrioNumbers = ""; if (!string.IsNullOrEmpty(currentScenario)) { int charLocation = currentScenario.IndexOf("", StringComparison.Ordinal); if (charLocation > 0) { scenrioNumbers = currentScenario.Substring(0, charLocation); } } return(scenrioNumbers); }
private void LoadInstallationScenario() { // These actions before & after Server installation scenario are necessary to syncronize // changes in setup variables during the installation AddAction(new SwapSetupVariablesForthAction { DataA = serverSetup }); CurrentScenario.AddRange(ServerActionManager.InstallScenario); AddAction(new SwapSetupVariablesBackAction { DataA = serverSetup }); // These actions before & after EnterpriseServer installation scenario are necessary to syncronize // changes in setup variables during the installation AddAction(new SwapSetupVariablesForthAction { DataA = esServerSetup }); CurrentScenario.AddRange(EntServerActionManager.InstallScenario); AddAction(new SwapSetupVariablesBackAction { DataA = esServerSetup }); // These actions before & after WebPortal installation scenario are necessary to syncronize // changes in setup variables during the installation AddAction(new SwapSetupVariablesForthAction { DataA = portalSetup }); CurrentScenario.AddRange(WebPortalActionManager.InstallScenario); AddAction(new SwapSetupVariablesBackAction { DataA = portalSetup }); // AddAction(new ConfigureStandaloneServerAction { ServerSetup = serverSetup, EnterpriseServerSetup = esServerSetup, PortalSetup = portalSetup }); }
public void TraceStepPending(BindingMatch match, object[] arguments) { if (CurrentScenario != null) { Status = Status.Failed; var errorRequest = new AddLogItemRequest { Level = LogLevel.Error, Time = DateTime.UtcNow.AddMilliseconds(1), Text = "One or more step definitions are not implemented yet.\r" + match.StepBinding.Method.Name + "(" + ")" }; CurrentScenario.Log(errorRequest); var request = new FinishTestItemRequest { Status = Status.Failed, EndTime = DateTime.UtcNow, Issue = new Issue { Type = IssueType.ToInvestigate, Comment = "Pending" } }; if (BeforeStepFinished != null) { BeforeStepFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, null)); } if (AfterStepFinished != null) { AfterStepFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, null)); } } }
public void TraceNoMatchingStepDefinition(StepInstance stepInstance, ProgrammingLanguage targetLanguage, System.Globalization.CultureInfo bindingCulture, List <BindingMatch> matchesWithoutScopeCheck) { if (CurrentScenario != null) { Status = Status.Failed; var errorRequest = new AddLogItemRequest { Level = LogLevel.Error, Time = DateTime.UtcNow.AddMilliseconds(1), Text = "No matching step definition." }; CurrentScenario.Log(errorRequest); var request = new FinishTestItemRequest { Status = Status.Failed, EndTime = DateTime.UtcNow, Issue = new Issue { Type = IssueType.AutomationBug, Comment = "No matching step definition." } }; if (BeforeStepFinished != null) { BeforeStepFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, null)); } if (AfterStepFinished != null) { AfterStepFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, null)); } } }
protected virtual void LoadInstallationScenario() { CurrentScenario.AddRange(InstallScenario); }
public StepContext(string text, Func <IStepContext, Task> body, StepType stepType) { Guard.AgainstNullArgument("body", body); this.step = CurrentScenario.AddStep(text, () => body(this), stepType); }
public Step(string text, Func <Task> body, StepType stepType) { this.step = CurrentScenario.AddStep(text, body, stepType); }
public Step(string text, Action body, StepType stepType) { this.step = CurrentScenario.AddStep(text, body, stepType); }
private void LoadInstallationScenario() { CurrentScenario.AddRange(InstallScenario); }
public static Fluent.IStep AddStep(string text, Action body) { return(new Fluent.Step(CurrentScenario.AddStep(text, body))); }