diff --git a/Runner/IMethodExecutor.cs b/Runner/IMethodExecutor.cs index 45a13ab..b3d0585 100644 --- a/Runner/IMethodExecutor.cs +++ b/Runner/IMethodExecutor.cs @@ -29,5 +29,6 @@ public interface IMethodExecutor ProtoExecutionResult ExecuteHooks(string hookType, HooksStrategy strategy, IList applicableTags, ExecutionContext executionContext); void ClearCache(); IEnumerable GetAllPendingMessages(); + IEnumerable GetAllPendingScreenshots(); } } \ No newline at end of file diff --git a/Runner/ISandbox.cs b/Runner/ISandbox.cs index 6e19682..d860fac 100644 --- a/Runner/ISandbox.cs +++ b/Runner/ISandbox.cs @@ -38,6 +38,7 @@ public interface ISandbox List GetAllStepTexts(); void ClearObjectCache(); IEnumerable GetAllPendingMessages(); + IEnumerable GetAllPendingScreenshots(); void StartExecutionScope(string tag); void CloseExectionScope(); ExecutionResult ExecuteHooks(string hookType, IHooksStrategy strategy, IList applicableTags, ExecutionContext executionContext); diff --git a/Runner/MethodExecutor.cs b/Runner/MethodExecutor.cs index 2a0a58f..b445f1d 100644 --- a/Runner/MethodExecutor.cs +++ b/Runner/MethodExecutor.cs @@ -99,6 +99,11 @@ public IEnumerable GetAllPendingMessages() return _sandbox.GetAllPendingMessages(); } + public IEnumerable GetAllPendingScreenshots() + { + return _sandbox.GetAllPendingScreenshots(); + } + private ByteString TakeScreenshot() { byte[] screenShotBytes; diff --git a/Runner/Processors/HookExecutionProcessor.cs b/Runner/Processors/HookExecutionProcessor.cs index 6455d0f..7deeb41 100644 --- a/Runner/Processors/HookExecutionProcessor.cs +++ b/Runner/Processors/HookExecutionProcessor.cs @@ -19,8 +19,6 @@ using System.Diagnostics; using System.Linq; using Gauge.CSharp.Core; -using Gauge.CSharp.Lib; -using Gauge.CSharp.Runner; using Gauge.CSharp.Runner.Strategy; using Gauge.Messages; diff --git a/Runner/Processors/StepExecutionEndingProcessor.cs b/Runner/Processors/StepExecutionEndingProcessor.cs index 2c7a34a..d834986 100644 --- a/Runner/Processors/StepExecutionEndingProcessor.cs +++ b/Runner/Processors/StepExecutionEndingProcessor.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Linq; using Gauge.Messages; +using Google.Protobuf; namespace Gauge.CSharp.Runner.Processors { @@ -34,7 +35,9 @@ protected override ProtoExecutionResult ExecuteHooks(Message request) { var protoExecutionResult = base.ExecuteHooks(request); var allPendingMessages = MethodExecutor.GetAllPendingMessages().Where(m => m != null); + var allPendingScreenshots = MethodExecutor.GetAllPendingScreenshots().Select(x => ByteString.CopyFrom(x)); protoExecutionResult.Message.AddRange(allPendingMessages); + protoExecutionResult.ScreenShot.AddRange(allPendingScreenshots); return protoExecutionResult; } diff --git a/Runner/Processors/StepExecutionStartingProcessor.cs b/Runner/Processors/StepExecutionStartingProcessor.cs index 52d1403..772c5d9 100644 --- a/Runner/Processors/StepExecutionStartingProcessor.cs +++ b/Runner/Processors/StepExecutionStartingProcessor.cs @@ -39,6 +39,7 @@ protected override ProtoExecutionResult ExecuteHooks(Message request) { // Just need to clear the messages, but Gauge.CSharp.Lib v0.5.2 does not have MessageCollector.Clear() MethodExecutor.GetAllPendingMessages(); + MethodExecutor.GetAllPendingScreenshots(); return base.ExecuteHooks(request); } diff --git a/Runner/Sandbox.cs b/Runner/Sandbox.cs index e77a9b2..36d88f4 100644 --- a/Runner/Sandbox.cs +++ b/Runner/Sandbox.cs @@ -185,6 +185,14 @@ public IEnumerable GetAllPendingMessages() return targetMethod.Invoke(null, null) as IEnumerable; } + public IEnumerable GetAllPendingScreenshots() + { + var targetMessageCollectorType = _libAssembly.GetType("Gauge.CSharp.Lib.ScreenshotCollector"); + var targetMethod = targetMessageCollectorType.GetMethod("GetAllPendingScreenshots", + BindingFlags.Static | BindingFlags.Public); + return targetMethod.Invoke(null, null) as IEnumerable; + } + public void StartExecutionScope(string tag) { _classInstanceManager.StartScope(tag); diff --git a/appveyor.yml b/appveyor.yml index f736fd3..14acb9f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,5 @@ version: 1.0.{build} +os: Visual Studio 2017 environment: GAUGE_PARALLEL: false GAUGE_TELEMETRY_ENABLED: false