Skip to content

Commit

Permalink
Programmatic skip scenario (#210)
Browse files Browse the repository at this point in the history
* Skip scenario during execution support

Signed-off-by: Piotr Nestorow <[email protected]>

* Send error info when skip scenario during runtime

Signed-off-by: Piotr Nestorow <[email protected]>

* Workflow LSP tests update

---------

Signed-off-by: Piotr Nestorow <[email protected]>
  • Loading branch information
PiotrNestor authored Jun 7, 2024
1 parent 19a6a36 commit 817fdaf
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 70 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ jobs:
- uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
Expand Down
19 changes: 13 additions & 6 deletions src/ExecutionOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,25 @@ private ProtoExecutionResult BuildResult(Stopwatch stopwatch, ExecutionResult ex
var result = new ProtoExecutionResult
{
Failed = false,
ExecutionTime = stopwatch.ElapsedMilliseconds
ExecutionTime = stopwatch.ElapsedMilliseconds,
SkipScenario = executionResult.SkipScenario
};
var allPendingMessages = GetAllPendingMessages().Where(m => m != null);
result.Message.AddRange(allPendingMessages);
var allPendingScreenShotFiles = GetAllPendingScreenshotFiles().Where(s => s != null);
result.ScreenshotFiles.AddRange(allPendingScreenShotFiles);

// If runtime skipped scenario return Error message and stack info
if (!string.IsNullOrEmpty(executionResult.ExceptionMessage))
{
result.ErrorMessage = executionResult.ExceptionMessage;
}
if (!string.IsNullOrEmpty(executionResult.StackTrace))
{
result.StackTrace = executionResult.StackTrace;
}
if (executionResult.Success) return result;

var elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
result.Failed = true;
var isScreenShotEnabled = Utils.TryReadEnvValue("SCREENSHOT_ON_FAILURE");
Expand All @@ -110,11 +122,6 @@ private ProtoExecutionResult BuildResult(Stopwatch stopwatch, ExecutionResult ex
}
}

result.ErrorMessage = executionResult.ExceptionMessage;
if (!string.IsNullOrEmpty(executionResult.StackTrace))
{
result.StackTrace = executionResult.StackTrace;
}
result.RecoverableError = executionResult.Recoverable;
result.ExecutionTime = elapsedMilliseconds;
return result;
Expand Down
129 changes: 85 additions & 44 deletions src/Gauge.CSharp.Core/Spec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,55 +104,56 @@ static SpecReflection() {
"AiABKAsyIC5nYXVnZS5tZXNzYWdlcy5Qcm90b0hvb2tGYWlsdXJlEjkKD3Bv",
"c3RIb29rRmFpbHVyZRgDIAEoCzIgLmdhdWdlLm1lc3NhZ2VzLlByb3RvSG9v",
"a0ZhaWx1cmUSDwoHc2tpcHBlZBgEIAEoCBIVCg1za2lwcGVkUmVhc29uGAUg",
"ASgJIosDChRQcm90b0V4ZWN1dGlvblJlc3VsdBIOCgZmYWlsZWQYASABKAgS",
"ASgJIqEDChRQcm90b0V4ZWN1dGlvblJlc3VsdBIOCgZmYWlsZWQYASABKAgS",
"GAoQcmVjb3ZlcmFibGVFcnJvchgCIAEoCBIUCgxlcnJvck1lc3NhZ2UYAyAB",
"KAkSEgoKc3RhY2tUcmFjZRgEIAEoCRIWCgpzY3JlZW5TaG90GAUgASgMQgIY",
"ARIVCg1leGVjdXRpb25UaW1lGAYgASgDEg8KB21lc3NhZ2UYByADKAkSQQoJ",
"ZXJyb3JUeXBlGAggASgOMi4uZ2F1Z2UubWVzc2FnZXMuUHJvdG9FeGVjdXRp",
"b25SZXN1bHQuRXJyb3JUeXBlEh0KEWZhaWx1cmVTY3JlZW5zaG90GAkgASgM",
"QgIYARIXCgtzY3JlZW5zaG90cxgKIAMoDEICGAESHQoVZmFpbHVyZVNjcmVl",
"bnNob3RGaWxlGAsgASgJEhcKD3NjcmVlbnNob3RGaWxlcxgMIAMoCSIsCglF",
"cnJvclR5cGUSDQoJQVNTRVJUSU9OEAASEAoMVkVSSUZJQ0FUSU9OEAEiqQE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IAEoCSJtChNQ",
"cm90b1NjZW5hcmlvUmVzdWx0EiwKCXByb3RvSXRlbRgBIAEoCzIZLmdhdWdl",
"Lm1lc3NhZ2VzLlByb3RvSXRlbRIVCg1leGVjdXRpb25UaW1lGAIgASgDEhEK",
"CXRpbWVzdGFtcBgDIAEoCSJpCg9Qcm90b1N0ZXBSZXN1bHQSLAoJcHJvdG9J",
"dGVtGAEgASgLMhkuZ2F1Z2UubWVzc2FnZXMuUHJvdG9JdGVtEhUKDWV4ZWN1",
"dGlvblRpbWUYAiABKAMSEQoJdGltZXN0YW1wGAMgASgJIqEBCgVFcnJvchIt",
"CgR0eXBlGAEgASgOMh8uZ2F1Z2UubWVzc2FnZXMuRXJyb3IuRXJyb3JUeXBl",
"EhAKCGZpbGVuYW1lGAIgASgJEhIKCmxpbmVOdW1iZXIYAyABKAUSDwoHbWVz",
"c2FnZRgEIAEoCSIyCglFcnJvclR5cGUSDwoLUEFSU0VfRVJST1IQABIUChBW",
"QUxJREFUSU9OX0VSUk9SEAEiVwoOUHJvdG9TdGVwVmFsdWUSEQoJc3RlcFZh",
"bHVlGAEgASgJEh4KFnBhcmFtZXRlcml6ZWRTdGVwVmFsdWUYAiABKAkSEgoK",
"cGFyYW1ldGVycxgDIAMoCSpHCg9FeGVjdXRpb25TdGF0dXMSDwoLTk9URVhF",
"Q1VURUQQABIKCgZQQVNTRUQQARIKCgZGQUlMRUQQAhILCgdTS0lQUEVEEANC",
"XAoWY29tLnRob3VnaHR3b3Jrcy5nYXVnZVoxZ2l0aHViLmNvbS9nZXRnYXVn",
"ZS9nYXVnZS1wcm90by9nby9nYXVnZV9tZXNzYWdlc6oCDkdhdWdlLk1lc3Nh",
"Z2VzYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Gauge.Messages.ExecutionStatus), }, null, new pbr::GeneratedClrTypeInfo[] {
Expand All @@ -170,7 +171,7 @@ static SpecReflection() {
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoTable), global::Gauge.Messages.ProtoTable.Parser, new[]{ "Headers", "Rows" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoTableRow), global::Gauge.Messages.ProtoTableRow.Parser, new[]{ "Cells" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoStepExecutionResult), global::Gauge.Messages.ProtoStepExecutionResult.Parser, new[]{ "ExecutionResult", "PreHookFailure", "PostHookFailure", "Skipped", "SkippedReason" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoExecutionResult), global::Gauge.Messages.ProtoExecutionResult.Parser, new[]{ "Failed", "RecoverableError", "ErrorMessage", "StackTrace", "ScreenShot", "ExecutionTime", "Message", "ErrorType", "FailureScreenshot", "Screenshots", "FailureScreenshotFile", "ScreenshotFiles" }, null, new[]{ typeof(global::Gauge.Messages.ProtoExecutionResult.Types.ErrorType) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoExecutionResult), global::Gauge.Messages.ProtoExecutionResult.Parser, new[]{ "Failed", "RecoverableError", "ErrorMessage", "StackTrace", "ScreenShot", "ExecutionTime", "Message", "ErrorType", "FailureScreenshot", "Screenshots", "FailureScreenshotFile", "ScreenshotFiles", "SkipScenario" }, null, new[]{ typeof(global::Gauge.Messages.ProtoExecutionResult.Types.ErrorType) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoHookFailure), global::Gauge.Messages.ProtoHookFailure.Parser, new[]{ "StackTrace", "ErrorMessage", "ScreenShot", "TableRowIndex", "FailureScreenshot", "FailureScreenshotFile" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoSuiteResult), global::Gauge.Messages.ProtoSuiteResult.Parser, new[]{ "SpecResults", "PreHookFailure", "PostHookFailure", "Failed", "SpecsFailedCount", "ExecutionTime", "SuccessRate", "Environment", "Tags", "ProjectName", "Timestamp", "SpecsSkippedCount", "PreHookMessages", "PostHookMessages", "PreHookMessage", "PostHookMessage", "PreHookScreenshots", "PostHookScreenshots", "Chunked", "ChunkSize", "PreHookScreenshotFiles", "PostHookScreenshotFiles" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoSpecResult), global::Gauge.Messages.ProtoSpecResult.Parser, new[]{ "ProtoSpec", "ScenarioCount", "ScenarioFailedCount", "Failed", "FailedDataTableRows", "ExecutionTime", "Skipped", "ScenarioSkippedCount", "SkippedDataTableRows", "Errors", "Timestamp" }, null, null, null, null),
Expand Down Expand Up @@ -5890,6 +5891,7 @@ public ProtoExecutionResult(ProtoExecutionResult other) : this() {
screenshots_ = other.screenshots_.Clone();
failureScreenshotFile_ = other.failureScreenshotFile_;
screenshotFiles_ = other.screenshotFiles_.Clone();
skipScenario_ = other.skipScenario_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

Expand Down Expand Up @@ -6079,6 +6081,21 @@ public string FailureScreenshotFile {
get { return screenshotFiles_; }
}

/// <summary>Field number for the "skipScenario" field.</summary>
public const int SkipScenarioFieldNumber = 13;
private bool skipScenario_;
/// <summary>
//// Flag to indicate skipping of the scenario execution
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool SkipScenario {
get { return skipScenario_; }
set {
skipScenario_ = value;
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
Expand Down Expand Up @@ -6106,6 +6123,7 @@ public bool Equals(ProtoExecutionResult other) {
if(!screenshots_.Equals(other.screenshots_)) return false;
if (FailureScreenshotFile != other.FailureScreenshotFile) return false;
if(!screenshotFiles_.Equals(other.screenshotFiles_)) return false;
if (SkipScenario != other.SkipScenario) return false;
return Equals(_unknownFields, other._unknownFields);
}

Expand All @@ -6125,6 +6143,7 @@ public override int GetHashCode() {
hash ^= screenshots_.GetHashCode();
if (FailureScreenshotFile.Length != 0) hash ^= FailureScreenshotFile.GetHashCode();
hash ^= screenshotFiles_.GetHashCode();
if (SkipScenario != false) hash ^= SkipScenario.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
Expand Down Expand Up @@ -6182,6 +6201,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteString(FailureScreenshotFile);
}
screenshotFiles_.WriteTo(output, _repeated_screenshotFiles_codec);
if (SkipScenario != false) {
output.WriteRawTag(104);
output.WriteBool(SkipScenario);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
Expand Down Expand Up @@ -6231,6 +6254,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteString(FailureScreenshotFile);
}
screenshotFiles_.WriteTo(ref output, _repeated_screenshotFiles_codec);
if (SkipScenario != false) {
output.WriteRawTag(104);
output.WriteBool(SkipScenario);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
Expand Down Expand Up @@ -6271,6 +6298,9 @@ public int CalculateSize() {
size += 1 + pb::CodedOutputStream.ComputeStringSize(FailureScreenshotFile);
}
size += screenshotFiles_.CalculateSize(_repeated_screenshotFiles_codec);
if (SkipScenario != false) {
size += 1 + 1;
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
Expand Down Expand Up @@ -6313,6 +6343,9 @@ public void MergeFrom(ProtoExecutionResult other) {
FailureScreenshotFile = other.FailureScreenshotFile;
}
screenshotFiles_.Add(other.screenshotFiles_);
if (other.SkipScenario != false) {
SkipScenario = other.SkipScenario;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

Expand Down Expand Up @@ -6376,6 +6409,10 @@ public void MergeFrom(pb::CodedInputStream input) {
screenshotFiles_.AddEntriesFrom(input, _repeated_screenshotFiles_codec);
break;
}
case 104: {
SkipScenario = input.ReadBool();
break;
}
}
}
#endif
Expand Down Expand Up @@ -6439,6 +6476,10 @@ public void MergeFrom(pb::CodedInputStream input) {
screenshotFiles_.AddEntriesFrom(ref input, _repeated_screenshotFiles_codec);
break;
}
case 104: {
SkipScenario = input.ReadBool();
break;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gauge.Dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<PackageId>Runner.NetCore30</PackageId>
<Authors>The Gauge Team</Authors>
<Version>0.5.7</Version>
<Version>0.5.8</Version>
<Company>ThoughtWorks Inc.</Company>
<Product>Gauge</Product>
<Description>C# runner for Gauge. https://gauge.org</Description>
Expand All @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Gauge.CSharp.Lib" Version="0.10.1" />
<PackageReference Include="Gauge.CSharp.Lib" Version="0.10.2" />
<PackageReference Include="Grpc.Tools" Version="2.61.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
28 changes: 21 additions & 7 deletions src/HookExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Gauge.Dotnet.Strategy;
using Gauge.Dotnet.Wrappers;
using Gauge.Messages;
using Gauge.CSharp.Lib.Attribute;

namespace Gauge.Dotnet
{
Expand All @@ -37,7 +38,8 @@ public ExecutionResult Execute(string hookType, IHooksStrategy strategy, IList<s
var methods = GetHookMethods(hookType, strategy, applicableTags);
var executionResult = new ExecutionResult
{
Success = true
Success = true,
SkipScenario = false
};
foreach (var method in methods)
{
Expand All @@ -49,12 +51,24 @@ public ExecutionResult Execute(string hookType, IHooksStrategy strategy, IList<s
}
catch (Exception ex)
{
Logger.Debug($"{hookType} Hook execution failed : {methodInfo.DeclaringType.FullName}.{methodInfo.Name}");
var innerException = ex.InnerException ?? ex;
executionResult.ExceptionMessage = innerException.Message;
executionResult.StackTrace = innerException.StackTrace;
executionResult.Source = innerException.Source;
executionResult.Success = false;
var baseException = ex.GetBaseException();
if (baseException != null &&
baseException.GetType().Name.Contains("SkipScenario", StringComparison.OrdinalIgnoreCase)) {
Logger.Debug($"Skipping scenario when executing hook: {methodInfo.DeclaringType.FullName}.{methodInfo.Name} : {baseException.Message}");
executionResult.StackTrace = baseException.StackTrace;
executionResult.ExceptionMessage = baseException.Message;
executionResult.Source = baseException.Source;
executionResult.Success = true;
executionResult.SkipScenario = true;
}
else {
Logger.Debug($"{hookType} Hook execution failed : {methodInfo.DeclaringType.FullName}.{methodInfo.Name}");
var innerException = ex.InnerException ?? ex;
executionResult.ExceptionMessage = innerException.Message;
executionResult.StackTrace = innerException.StackTrace;
executionResult.Source = innerException.Source;
executionResult.Success = false;
}
}
}

Expand Down
Loading

0 comments on commit 817fdaf

Please sign in to comment.