public void ShouldCaptureScreenshotOnFailure() { const string stepText = "I throw a serializable exception"; var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var path = new AssemblyLocater(new DirectoryWrapper()).GetTestAssembly(); var assemblyLoader = new AssemblyLoader(path, new GaugeLoadContext(path), reflectionWrapper, activatorWrapper, new StepRegistry()); var classInstanceManager = new ThreadLocal <object>(() => assemblyLoader.GetClassInstanceManager()); var executionInfoMapper = new ExecutionInfoMapper(assemblyLoader, activatorWrapper); var orchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager, executionInfoMapper), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), orchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var message = new ExecuteStepRequest { ParsedStepText = stepText, ActualStepText = stepText }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsTrue(protoExecutionResult.Failed); Assert.AreEqual("screenshot.png", protoExecutionResult.FailureScreenshotFile); }
private void InitializeExecutionMessageHandlers() { var activatorWrapper = new ActivatorWrapper(); var reflectionWrapper = new ReflectionWrapper(); var assemblies = new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), assemblies, reflectionWrapper, activatorWrapper); _stepRegistry = assemblyLoader.GetStepRegistry(); var tableFormatter = new TableFormatter(assemblyLoader, activatorWrapper); var classInstanceManager = assemblyLoader.GetClassInstanceManager(); var executionOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); this.executionStartingProcessor = new ExecutionStartingProcessor(executionOrchestrator); this.executionEndingProcessor = new ExecutionEndingProcessor(executionOrchestrator); this.specExecutionStartingProcessor = new SpecExecutionStartingProcessor(executionOrchestrator); this.specExecutionEndingProcessor = new SpecExecutionEndingProcessor(executionOrchestrator); this.scenarioExecutionStartingProcessor = new ScenarioExecutionStartingProcessor(executionOrchestrator); this.scenarioExecutionEndingProcessor = new ScenarioExecutionEndingProcessor(executionOrchestrator); this.stepExecutionStartingProcessor = new StepExecutionStartingProcessor(executionOrchestrator); this.stepExecutionEndingProcessor = new StepExecutionEndingProcessor(executionOrchestrator); this.executeStepProcessor = new ExecuteStepProcessor(_stepRegistry, executionOrchestrator, tableFormatter); this.scenarioDataStoreInitProcessor = new ScenarioDataStoreInitProcessor(assemblyLoader); this.specDataStoreInitProcessor = new SpecDataStoreInitProcessor(assemblyLoader); this.suiteDataStoreInitProcessor = new SuiteDataStoreInitProcessor(assemblyLoader); }
public void ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.ParameterType parameterType) { const string parsedStepText = "Foo"; var protoTable = new ProtoTable(); var headers = new ProtoTableRow(); headers.Cells.AddRange(new List <string> { "foo", "bar" }); protoTable.Headers = headers; var row = new ProtoTableRow(); row.Cells.AddRange(new List <string> { "foorow1", "foorow2" }); protoTable.Rows.AddRange(new List <ProtoTableRow>() { row }); var request = new Message() { MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest() { ActualStepText = parsedStepText, ParsedStepText = parsedStepText, Parameters = { new Parameter() { ParameterType = parameterType, Table = protoTable } }, }, MessageId = 20 }; var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true); var fooMethodInfo = new GaugeMethod { Name = "Foo", ParameterCount = 1 }; mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockMethodExecutor = new Mock <IMethodExecutor>(); mockMethodExecutor.Setup(e => e.Execute(fooMethodInfo, It.IsAny <string[]>())).Returns(() => new ProtoExecutionResult() { ExecutionTime = 1, Failed = false }); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockMethodExecutor.Object).Process(request); mockMethodExecutor.Verify(executor => executor.Execute(fooMethodInfo, It.Is <string[]>(strings => HasTable(strings)))); Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed); }
public void ShouldRegisterScreenshotWriterFromReference(string stepText, string expected) { var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(), reflectionWrapper, activatorWrapper, new StepRegistry()); var classInstanceManager = assemblyLoader.GetClassInstanceManager(); var mockOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), mockOrchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var message = new ExecuteStepRequest { ParsedStepText = stepText, ActualStepText = stepText }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.AreEqual(protoExecutionResult.ScreenshotFiles[0], expected); }
public void ShouldReportArgumentMismatch() { const string parsedStepText = "Foo"; var request = Message.CreateBuilder() .SetMessageType(Message.Types.MessageType.ExecuteStep) .SetExecuteStepRequest( ExecuteStepRequest.CreateBuilder() .SetActualStepText(parsedStepText) .SetParsedStepText(parsedStepText) .Build()) .SetMessageId(20) .Build(); var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true); var fooMethodInfo = GetType().GetMethod("Foo"); mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockMethodExecutor = new Mock <IMethodExecutor>(); var mockSandbox = new Mock <ISandbox>(); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockMethodExecutor.Object, mockSandbox.Object).Process(request); Assert.True(response.ExecutionStatusResponse.ExecutionResult.Failed); Assert.AreEqual(response.ExecutionStatusResponse.ExecutionResult.ErrorMessage, "Argument length mismatch for Foo. Actual Count: 0, Expected Count: 1"); }
public void ShouldProcessExecuteStepRequest() { const string parsedStepText = "Foo"; var request = Message.CreateBuilder() .SetMessageType(Message.Types.MessageType.ExecuteStep) .SetExecuteStepRequest( ExecuteStepRequest.CreateBuilder() .SetActualStepText(parsedStepText) .SetParsedStepText(parsedStepText) .AddParameters( Parameter.CreateBuilder() .SetParameterType(Parameter.Types.ParameterType.Static) .SetName("Foo") .SetValue("Bar") .Build()) .Build()) .SetMessageId(20) .Build(); var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true); var fooMethodInfo = GetType().GetMethod("Foo"); mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockMethodExecutor = new Mock <IMethodExecutor>(); mockMethodExecutor.Setup(e => e.Execute(fooMethodInfo, It.IsAny <Object[]>())).Returns(() => ProtoExecutionResult.CreateBuilder().SetExecutionTime(1).SetFailed(false).Build()); var mockSandbox = new Mock <ISandbox>(); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockMethodExecutor.Object, mockSandbox.Object).Process(request); Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed); }
public void ShouldCaptureScreenshotOnFailure() { const string parameterizedStepText = "I throw a serializable exception"; const string stepText = "I throw a serializable exception"; var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(), reflectionWrapper, activatorWrapper); var classInstanceManager = assemblyLoader.GetClassInstanceManager(); var mockOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), mockOrchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var message = new ExecuteStepRequest { ParsedStepText = parameterizedStepText, ActualStepText = stepText }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsTrue(protoExecutionResult.Failed); Assert.AreEqual(protoExecutionResult.FailureScreenshotFile, "screenshot.png"); }
public void ShouldReportArgumentMismatch() { const string parsedStepText = "Foo"; var request = new Message { MessageType = Message.Types.MessageType.ExecuteStep, MessageId = 20, ExecuteStepRequest = new ExecuteStepRequest { ActualStepText = parsedStepText, ParsedStepText = parsedStepText } }; var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true); var fooMethod = new GaugeMethod { Name = "Foo", ParameterCount = 1 }; mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethod); var mockOrchestrator = new Mock <IExecutionOrchestrator>(); var mockTableFormatter = new Mock <ITableFormatter>(); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object) .Process(request); Assert.True(response.ExecutionStatusResponse.ExecutionResult.Failed); Assert.AreEqual(response.ExecutionStatusResponse.ExecutionResult.ErrorMessage, "Argument length mismatch for Foo. Actual Count: 0, Expected Count: 1"); }
public void ShouldReportMissingStep() { const string parsedStepText = "Foo"; var request = new Message { MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest { ActualStepText = parsedStepText, ParsedStepText = parsedStepText }, MessageId = 20 }; var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(false); var mockOrchestrator = new Mock <IExecutionOrchestrator>(); var mockTableFormatter = new Mock <ITableFormatter>(); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object) .Process(request); Assert.True(response.ExecutionStatusResponse.ExecutionResult.Failed); Assert.AreEqual(response.ExecutionStatusResponse.ExecutionResult.ErrorMessage, "Step Implementation not found"); }
private void InitializeExecutionMessageHandlers() { var tableFormatter = new TableFormatter(this._assemblyLoader, this._activatorWrapper); var classInstanceManager = new ThreadLocal <object>(() => { return(this._assemblyLoader.GetClassInstanceManager()); }); var executionInfoMapper = new ExecutionInfoMapper(this._assemblyLoader, this._activatorWrapper); var executionOrchestrator = new ExecutionOrchestrator(this._reflectionWrapper, this._assemblyLoader, classInstanceManager.Value, new HookExecutor(this._assemblyLoader, this._reflectionWrapper, classInstanceManager.Value, executionInfoMapper), new StepExecutor(this._assemblyLoader, this._reflectionWrapper, classInstanceManager.Value)); this.executionStartingProcessor = new ExecutionStartingProcessor(executionOrchestrator); this.executionEndingProcessor = new ExecutionEndingProcessor(executionOrchestrator); this.specExecutionStartingProcessor = new SpecExecutionStartingProcessor(executionOrchestrator); this.specExecutionEndingProcessor = new SpecExecutionEndingProcessor(executionOrchestrator); this.scenarioExecutionStartingProcessor = new ScenarioExecutionStartingProcessor(executionOrchestrator); this.scenarioExecutionEndingProcessor = new ScenarioExecutionEndingProcessor(executionOrchestrator); this.stepExecutionStartingProcessor = new StepExecutionStartingProcessor(executionOrchestrator); this.stepExecutionEndingProcessor = new StepExecutionEndingProcessor(executionOrchestrator); this.executeStepProcessor = new ExecuteStepProcessor(_stepRegistry, executionOrchestrator, tableFormatter); this.scenarioDataStoreInitProcessor = new ScenarioDataStoreInitProcessor(this._assemblyLoader); this.specDataStoreInitProcessor = new SpecDataStoreInitProcessor(this._assemblyLoader); this.suiteDataStoreInitProcessor = new SuiteDataStoreInitProcessor(this._assemblyLoader); }
public void ShouldRegisterScreenshotWriterFromReference(string referenceType, string stepText, string expected) { Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", TestUtils.GetIntegrationTestSampleDirectory(referenceType)); var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var path = new AssemblyLocater(new DirectoryWrapper()).GetTestAssembly(); var assemblyLoader = new AssemblyLoader(path, new GaugeLoadContext(path), reflectionWrapper, activatorWrapper, new StepRegistry()); var classInstanceManager = new ThreadLocal <object>(() => assemblyLoader.GetClassInstanceManager()).Value; var executionInfoMapper = new ExecutionInfoMapper(assemblyLoader, activatorWrapper); var executionOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager, executionInfoMapper), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), executionOrchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var message = new ExecuteStepRequest { ParsedStepText = stepText, ActualStepText = stepText }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Console.WriteLine(protoExecutionResult.ScreenshotFiles[0]); Assert.AreEqual(protoExecutionResult.ScreenshotFiles[0], expected); }
public void ShouldExecuteMethodFromRequest() { const string parameterizedStepText = "Step that takes a table {}"; const string stepText = "Step that takes a table <table>"; var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(), reflectionWrapper); var classInstanceManager = assemblyLoader.GetClassInstanceManager(activatorWrapper); var mockOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), mockOrchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var protoTable = new ProtoTable { Headers = new ProtoTableRow { Cells = { "foo", "bar" } }, Rows = { new ProtoTableRow { Cells ={ "foorow1", "foorow2" } } } }; var message = new Message { MessageId = 1234, MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest { ParsedStepText = parameterizedStepText, ActualStepText = stepText, Parameters = { new Parameter { Name = "table", ParameterType = Parameter.Types.ParameterType.Table, Table = protoTable } } } }; var result = executeStepProcessor.Process(message); AssertRunnerDomainDidNotLoadUsersAssembly(); var protoExecutionResult = result.ExecutionStatusResponse.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsFalse(protoExecutionResult.Failed); }
public void ShouldExecuteMethodFromRequest() { const string parameterizedStepText = "Step that takes a table {}"; const string stepText = "Step that takes a table <table>"; var sandbox = SandboxBuilder.Build(); var gaugeMethod = sandbox.GetStepMethods() .First(method => method.Name == "IntegrationTestSample.StepImplementation.ReadTable-Tabletable"); var scannedSteps = new List <KeyValuePair <string, GaugeMethod> > { new KeyValuePair <string, GaugeMethod>(parameterizedStepText, gaugeMethod) }; var aliases = new Dictionary <string, bool> { { parameterizedStepText, false } }; var stepTextMap = new Dictionary <string, string> { { parameterizedStepText, stepText } }; var stepRegistry = new StepRegistry(scannedSteps, stepTextMap, aliases); var executeStepProcessor = new ExecuteStepProcessor(stepRegistry, new MethodExecutor(sandbox)); var protoTable = new ProtoTable() { Headers = new ProtoTableRow() { Cells = { "foo", "bar" } }, Rows = { new ProtoTableRow() { Cells ={ "foorow1", "foorow2" } } } }; var message = new Message() { MessageId = 1234, MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest() { ParsedStepText = parameterizedStepText, ActualStepText = stepText, Parameters = { new Parameter() { Name = "table", ParameterType = Parameter.Types.ParameterType.Table, Table = protoTable } } } }; var result = executeStepProcessor.Process(message); AssertRunnerDomainDidNotLoadUsersAssembly(); var protoExecutionResult = result.ExecutionStatusResponse.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsFalse(protoExecutionResult.Failed); }
public void ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.ParameterType parameterType) { const string parsedStepText = "Foo"; var protoTable = new ProtoTable(); var tableJSON = "{'headers':['foo', 'bar'],'rows':[['foorow1','barrow1']]}"; var request = new Message { MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest { ActualStepText = parsedStepText, ParsedStepText = parsedStepText, Parameters = { new Parameter { ParameterType = parameterType, Table = protoTable } } }, MessageId = 20 }; var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true); var fooMethodInfo = new GaugeMethod { Name = "Foo", ParameterCount = 1 }; mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockOrchestrator = new Mock <IExecutionOrchestrator>(); mockOrchestrator.Setup(e => e.ExecuteStep(fooMethodInfo, It.IsAny <string[]>())).Returns(() => new ProtoExecutionResult { ExecutionTime = 1, Failed = false }); var mockAssemblyLoader = new Mock <IAssemblyLoader>(); mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)); var mockTableFormatter = new Mock <ITableFormatter>(); mockTableFormatter.Setup(x => x.GetJSON(protoTable)) .Returns(tableJSON); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object) .Process(request); mockOrchestrator.Verify(executor => executor.ExecuteStep(fooMethodInfo, It.Is <string[]>(strings => strings[0] == tableJSON))); Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed); }
public void ShouldExecuteMethodFromRequest() { const string parameterizedStepText = "Step that takes a table {}"; const string stepText = "Step that takes a table <table>"; var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var path = new AssemblyLocater(new DirectoryWrapper()).GetTestAssembly(); var assemblyLoader = new AssemblyLoader(path, new GaugeLoadContext(path), reflectionWrapper, activatorWrapper, new StepRegistry()); var executionInfoMapper = new ExecutionInfoMapper(assemblyLoader, activatorWrapper); var classInstanceManager = assemblyLoader.GetClassInstanceManager(); var orchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager, executionInfoMapper), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), orchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var protoTable = new ProtoTable { Headers = new ProtoTableRow { Cells = { "foo", "bar" } }, Rows = { new ProtoTableRow { Cells ={ "foorow1", "foorow2" } } } }; var message = new ExecuteStepRequest { ParsedStepText = parameterizedStepText, ActualStepText = stepText, Parameters = { new Parameter { Name = "table", ParameterType = Parameter.Types.ParameterType.Table, Table = protoTable } } }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsFalse(protoExecutionResult.Failed); }
public void ShouldProcessExecuteStepRequest() { const string parsedStepText = "Foo"; var request = new Message { MessageType = Message.Types.MessageType.ExecuteStep, MessageId = 20, ExecuteStepRequest = new ExecuteStepRequest { ActualStepText = parsedStepText, ParsedStepText = parsedStepText, Parameters = { new Parameter { ParameterType = Parameter.Types.ParameterType.Static, Name = "Foo", Value = "Bar" } } } }; var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true); var fooMethodInfo = new GaugeMethod { Name = "Foo", ParameterCount = 1 }; mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockOrchestrator = new Mock <IExecutionOrchestrator>(); mockOrchestrator.Setup(e => e.ExecuteStep(fooMethodInfo, It.IsAny <string[]>())) .Returns(() => new ProtoExecutionResult { ExecutionTime = 1, Failed = false }); var mockTableFormatter = new Mock <ITableFormatter>(); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object) .Process(request); Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed); }
public void ShouldCaptureScreenshotOnFailure() { const string parameterizedStepText = "I throw a serializable exception"; const string stepText = "I throw a serializable exception"; var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(), reflectionWrapper); var sandbox = new Sandbox(assemblyLoader, new HookRegistry(assemblyLoader), activatorWrapper, reflectionWrapper); var gaugeMethod = sandbox.GetStepMethods() .First(method => method.Name == "IntegrationTestSample.StepImplementation.ThrowSerializableException"); var scannedSteps = new List <KeyValuePair <string, GaugeMethod> > { new KeyValuePair <string, GaugeMethod>(parameterizedStepText, gaugeMethod) }; var aliases = new Dictionary <string, bool> { { parameterizedStepText, false } }; var stepTextMap = new Dictionary <string, string> { { parameterizedStepText, stepText } }; var stepRegistry = new StepRegistry(scannedSteps, stepTextMap, aliases); var executeStepProcessor = new ExecuteStepProcessor(stepRegistry, new MethodExecutor(sandbox), new TableFormatter(assemblyLoader, activatorWrapper)); var message = new Message { MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest { ParsedStepText = parameterizedStepText, ActualStepText = stepText } }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionStatusResponse.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsTrue(protoExecutionResult.Failed); Assert.AreEqual(Encoding.UTF8.GetString(protoExecutionResult.ScreenShot.ToByteArray()), "ScreenShot"); }
public void ShouldReportMissingStep() { const string parsedStepText = "Foo"; var request = Message.CreateBuilder() .SetMessageType(Message.Types.MessageType.ExecuteStep) .SetExecuteStepRequest( ExecuteStepRequest.CreateBuilder() .SetActualStepText(parsedStepText) .SetParsedStepText(parsedStepText) .Build()) .SetMessageId(20) .Build(); var mockStepRegistry = new Mock <IStepRegistry>(); mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(false); var mockMethodExecutor = new Mock <IMethodExecutor>(); var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockMethodExecutor.Object).Process(request); Assert.True(response.ExecutionStatusResponse.ExecutionResult.Failed); Assert.AreEqual(response.ExecutionStatusResponse.ExecutionResult.ErrorMessage, "Step Implementation not found"); }
public void ShouldCaptureScreenshotOnFailure() { const string parameterizedStepText = "I throw a serializable exception"; const string stepText = "I throw a serializable exception"; var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(), reflectionWrapper); var classInstanceManager = assemblyLoader.GetClassInstanceManager(activatorWrapper); var mockOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); var executeStepProcessor = new ExecuteStepProcessor(assemblyLoader.GetStepRegistry(), mockOrchestrator, new TableFormatter(assemblyLoader, activatorWrapper)); var message = new Message { MessageType = Message.Types.MessageType.ExecuteStep, ExecuteStepRequest = new ExecuteStepRequest { ParsedStepText = parameterizedStepText, ActualStepText = stepText } }; var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionStatusResponse.ExecutionResult; Assert.IsNotNull(protoExecutionResult); Assert.IsTrue(protoExecutionResult.Failed); Assert.AreEqual(protoExecutionResult.ScreenShot.Count, 1); Assert.AreEqual(Encoding.UTF8.GetString(protoExecutionResult.ScreenShot[0].ToByteArray()), "ScreenShot"); }