Skip to content

Commit

Permalink
Revert "check if method is async and await results, #199 (#201)"
Browse files Browse the repository at this point in the history
This reverts commit b7550c9.
  • Loading branch information
sriv committed Feb 13, 2024
1 parent b7550c9 commit 2523639
Show file tree
Hide file tree
Showing 53 changed files with 219 additions and 374 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@ deploy
artifacts
.ionide
.DS_Store
.fake
.idea
Gauge.Dotnet.sln.DotSettings.user
_testdata/Sample/.gauge/
_testdata/Sample/logs/
_testdata/Sample/reports/
.fake
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ gauge run specs
#### Install specific version

```
gauge install dotnet --version 0.6.0
gauge install dotnet --version 0.5.2
```

#### Offline installation

Download the plugin from [Releases](https://github.com/getgauge/gauge-dotnet/releases)

```
gauge install dotnet --file gauge-dotnet-0.6.0.zip
gauge install dotnet --file gauge-dotnet-0.5.2.zip
```

#### Build from Source
Expand Down
2 changes: 1 addition & 1 deletion _testdata/Sample/IntegrationTestSample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 0 additions & 8 deletions _testdata/Sample/StepImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ public void SaySomething(string what, string who)
GaugeMessages.WriteMessage("{0}, {1}!", what, who);
}

[Step("Say <what> to <who> async")]
public async Task SaySomethingAsync(string what, string who)
{
Console.WriteLine("{0}, {1}!", what, who);
GaugeMessages.WriteMessage("{0}, {1}!", what, who);
await Task.Delay(100);
}

[Step("I throw an unserializable exception")]
public void ThrowUnserializableException()
{
Expand Down
5 changes: 2 additions & 3 deletions _testdata/Sample/gauge_bin/IntegrationTestSample.deps.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0/linux-x64",
"name": ".NETCoreApp,Version=v3.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {},
".NETCoreApp,Version=v7.0/linux-x64": {
".NETCoreApp,Version=v3.0": {
"IntegrationTestSample/1.0.0": {
"dependencies": {
"Gauge.CSharp.Lib": "0.7.6"
Expand Down
Binary file modified _testdata/Sample/gauge_bin/IntegrationTestSample.dll
Binary file not shown.
Binary file modified _testdata/Sample/gauge_bin/IntegrationTestSample.pdb
Binary file not shown.
9 changes: 4 additions & 5 deletions integration-test/ExecuteStepProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


using System.Threading;
using System.Threading.Tasks;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Processors;
using Gauge.Dotnet.Wrappers;
Expand All @@ -19,7 +18,7 @@ namespace Gauge.Dotnet.IntegrationTests
public class ExecuteStepProcessorTests : IntegrationTestsBase
{
[Test]
public async Task ShouldExecuteMethodFromRequest()
public void ShouldExecuteMethodFromRequest()
{
const string parameterizedStepText = "Step that takes a table {}";
const string stepText = "Step that takes a table <table>";
Expand Down Expand Up @@ -65,15 +64,15 @@ public async Task ShouldExecuteMethodFromRequest()
}
}
};
var result = await executeStepProcessor.Process(message);
var result = executeStepProcessor.Process(message);

var protoExecutionResult = result.ExecutionResult;
ClassicAssert.IsNotNull(protoExecutionResult);
ClassicAssert.IsFalse(protoExecutionResult.Failed);
}

[Test]
public async Task ShouldCaptureScreenshotOnFailure()
public void ShouldCaptureScreenshotOnFailure()
{
const string stepText = "I throw a serializable exception";
var reflectionWrapper = new ReflectionWrapper();
Expand All @@ -97,7 +96,7 @@ public async Task ShouldCaptureScreenshotOnFailure()
ActualStepText = stepText
};

var result = await executeStepProcessor.Process(message);
var result = executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;

ClassicAssert.IsNotNull(protoExecutionResult);
Expand Down
52 changes: 15 additions & 37 deletions integration-test/ExecutionOrchestratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Gauge.CSharp.Lib;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Wrappers;
Expand All @@ -20,7 +19,7 @@ namespace Gauge.Dotnet.IntegrationTests
public class ExecutionOrchestratorTests : IntegrationTestsBase
{
[Test]
public async Task RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
public void RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
Expand All @@ -34,13 +33,13 @@ public async Task RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));
var gaugeMethod = assemblyLoader.GetStepRegistry()
.MethodFor("I throw a serializable exception and continue");
var executionResult = await orchestrator.ExecuteStep(gaugeMethod);
var executionResult = orchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.IsTrue(executionResult.Failed);
ClassicAssert.IsTrue(executionResult.RecoverableError);
}

[Test]
public async Task ShouldCreateTableFromTargetType()
public void ShouldCreateTableFromTargetType()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
Expand All @@ -57,12 +56,12 @@ public async Task ShouldCreateTableFromTargetType()
table.AddRow(new List<string> { "foorow1", "barrow1" });
table.AddRow(new List<string> { "foorow2", "barrow2" });

var executionResult = await orchestrator.ExecuteStep(gaugeMethod, SerializeTable(table));
var executionResult = orchestrator.ExecuteStep(gaugeMethod, SerializeTable(table));
ClassicAssert.False(executionResult.Failed);
}

[Test]
public async Task ShouldExecuteMethodAndReturnResult()
public void ShouldExecuteMethodAndReturnResult()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
Expand All @@ -77,12 +76,13 @@ public async Task ShouldExecuteMethodAndReturnResult()
var gaugeMethod = assemblyLoader.GetStepRegistry()
.MethodFor("A context step which gets executed before every scenario");

var executionResult = await orchestrator.ExecuteStep(gaugeMethod);
var executionResult = orchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.False(executionResult.Failed);
}


[Test]
public async Task ShouldGetPendingMessages()
public void ShouldGetPendingMessages()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
Expand All @@ -97,36 +97,14 @@ public async Task ShouldGetPendingMessages()

var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("Say {} to {}");

var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "world");
var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "world");

ClassicAssert.False(executionResult.Failed);
ClassicAssert.Contains("hello, world!", executionResult.Message);
}

[Test]
public async Task ShouldExecuteAsyncStepImplementation()
{
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 = assemblyLoader.GetClassInstanceManager();
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 gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("Say {} to {} async");

var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "async world");

Assert.That(executionResult.Failed, Is.False, executionResult.ErrorMessage);
StringAssert.Contains("hello, async world!", executionResult.Message.ToString());
}

[Test]
public async Task ShouldGetStacktraceForAggregateException()
public void ShouldGetStacktraceForAggregateException()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
Expand All @@ -140,7 +118,7 @@ public async Task ShouldGetStacktraceForAggregateException()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));

var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an AggregateException");
var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod);
var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);

ClassicAssert.True(executionResult.Failed);
ClassicAssert.True(executionResult.StackTrace.Contains("First Exception"));
Expand All @@ -163,7 +141,7 @@ public void ShouldGetStepTextsForMethod()
}

[Test]
public async Task SuccessIsFalseOnSerializableExceptionThrown()
public void SuccessIsFalseOnSerializableExceptionThrown()
{
const string expectedMessage = "I am a custom serializable exception";
var reflectionWrapper = new ReflectionWrapper();
Expand All @@ -178,7 +156,7 @@ public async Task SuccessIsFalseOnSerializableExceptionThrown()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw a serializable exception");

var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod);
var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);

ClassicAssert.True(executionResult.Failed);
ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage);
Expand All @@ -187,7 +165,7 @@ public async Task SuccessIsFalseOnSerializableExceptionThrown()
}

[Test]
public async Task SuccessIsFalseOnUnserializableExceptionThrown()
public void SuccessIsFalseOnUnserializableExceptionThrown()
{
const string expectedMessage = "I am a custom exception";
var reflectionWrapper = new ReflectionWrapper();
Expand All @@ -202,7 +180,7 @@ public async Task SuccessIsFalseOnUnserializableExceptionThrown()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));

var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an unserializable exception");
var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod);
var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.True(executionResult.Failed);
ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage);
StringAssert.Contains("IntegrationTestSample.StepImplementation.ThrowUnserializableException",
Expand Down
5 changes: 2 additions & 3 deletions integration-test/ExternalReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using System;
using System.Threading;
using System.Threading.Tasks;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Processors;
using Gauge.Dotnet.Wrappers;
Expand Down Expand Up @@ -44,7 +43,7 @@ public void ShouldGetStepsFromReference(string referenceType, string stepText, s
[Test]
[TestCase("ProjectReference", "Take Screenshot in reference Project", "ReferenceProject-IDoNotExist.png")]
[TestCase("DllReference", "Take Screenshot in reference DLL", "ReferenceDll-IDoNotExist.png")]
public async Task ShouldRegisterScreenshotWriterFromReference(string referenceType, string stepText, string expected)
public void ShouldRegisterScreenshotWriterFromReference(string referenceType, string stepText, string expected)
{
Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", TestUtils.GetIntegrationTestSampleDirectory(referenceType));
var reflectionWrapper = new ReflectionWrapper();
Expand All @@ -67,7 +66,7 @@ public async Task ShouldRegisterScreenshotWriterFromReference(string referenceTy
ActualStepText = stepText
};

var result = await executeStepProcessor.Process(message);
var result = executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;

ClassicAssert.IsNotNull(protoExecutionResult);
Expand Down
2 changes: 1 addition & 1 deletion integration-test/ImplementCodeProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void ShouldProcessMessageForExistingClass()
var result = processor.Process(message);
ClassicAssert.AreEqual(1, result.TextDiffs.Count);
StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
ClassicAssert.AreEqual(115, result.TextDiffs[0].Span.Start);
ClassicAssert.AreEqual(107, result.TextDiffs[0].Span.Start);
}

[Test]
Expand Down
Loading

0 comments on commit 2523639

Please sign in to comment.