Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

add support for capturing ScreenShot in Step, getgauge/gauge#632 #135

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Runner/IMethodExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public interface IMethodExecutor
ProtoExecutionResult ExecuteHooks(string hookType, HooksStrategy strategy, IList<string> applicableTags, ExecutionContext executionContext);
void ClearCache();
IEnumerable<string> GetAllPendingMessages();
IEnumerable<byte[]> GetAllPendingScreenshots();
}
}
1 change: 1 addition & 0 deletions Runner/ISandbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface ISandbox
List<string> GetAllStepTexts();
void ClearObjectCache();
IEnumerable<string> GetAllPendingMessages();
IEnumerable<byte[]> GetAllPendingScreenshots();
void StartExecutionScope(string tag);
void CloseExectionScope();
ExecutionResult ExecuteHooks(string hookType, IHooksStrategy strategy, IList<string> applicableTags, ExecutionContext executionContext);
Expand Down
5 changes: 5 additions & 0 deletions Runner/MethodExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public IEnumerable<string> GetAllPendingMessages()
return _sandbox.GetAllPendingMessages();
}

public IEnumerable<byte[]> GetAllPendingScreenshots()
{
return _sandbox.GetAllPendingScreenshots();
}

private ByteString TakeScreenshot()
{
byte[] screenShotBytes;
Expand Down
2 changes: 0 additions & 2 deletions Runner/Processors/HookExecutionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions Runner/Processors/StepExecutionEndingProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Linq;
using Gauge.Messages;
using Google.Protobuf;

namespace Gauge.CSharp.Runner.Processors
{
Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions Runner/Processors/StepExecutionStartingProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions Runner/Sandbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ public IEnumerable<string> GetAllPendingMessages()
return targetMethod.Invoke(null, null) as IEnumerable<string>;
}

public IEnumerable<byte[]> 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<byte[]>;
}

public void StartExecutionScope(string tag)
{
_classInstanceManager.StartScope(tag);
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: 1.0.{build}
os: Visual Studio 2017
environment:
GAUGE_PARALLEL: false
GAUGE_TELEMETRY_ENABLED: false
Expand Down