From 252363949ae057bff4051a95d39777cd93dbe528 Mon Sep 17 00:00:00 2001 From: sriv Date: Tue, 13 Feb 2024 14:28:29 +0530 Subject: [PATCH] Revert "check if method is async and await results, #199 (#201)" This reverts commit b7550c94fadaa1cc2d7a241d4e631117a0874dbe. --- .gitignore | 7 +- README.MD | 4 +- _testdata/Sample/IntegrationTestSample.csproj | 2 +- _testdata/Sample/StepImplementation.cs | 8 -- .../gauge_bin/IntegrationTestSample.deps.json | 5 +- .../gauge_bin/IntegrationTestSample.dll | Bin 10240 -> 8704 bytes .../gauge_bin/IntegrationTestSample.pdb | Bin 12104 -> 2492 bytes integration-test/ExecuteStepProcessorTests.cs | 9 +- .../ExecutionOrchestratorTests.cs | 52 ++++------- integration-test/ExternalReferenceTests.cs | 5 +- .../ImplementCodeProcessorTests.cs | 2 +- src/ExecutableRunnerServiceHandler.cs | 81 ++++++++++-------- src/ExecutionOrchestrator.cs | 10 +-- src/Executor/ExecutorPool.cs | 23 ++--- src/Extensions/MethodInfoExtensions.cs | 6 -- src/Gauge.Dotnet.csproj | 2 +- src/HookExecutor.cs | 11 ++- src/IExecutionOrchestrator.cs | 5 +- src/IHookExecutor.cs | 3 +- src/IStepExecutor.cs | 3 +- src/MethodExecutor.cs | 12 +-- src/Models/GaugeMethod.cs | 2 +- src/Models/IStepRegistry.cs | 1 - src/Models/StepRegistry.cs | 6 -- src/Processors/ExecuteStepProcessor.cs | 5 +- src/Processors/ExecutionEndingProcessor.cs | 5 +- src/Processors/ExecutionStartingProcessor.cs | 5 +- src/Processors/HookExecutionProcessor.cs | 5 +- .../ScenarioExecutionEndingProcessor.cs | 5 +- .../ScenarioExecutionStartingProcessor.cs | 5 +- .../SpecExecutionEndingProcessor.cs | 5 +- .../SpecExecutionStartingProcessor.cs | 5 +- .../StepExecutionEndingProcessor.cs | 5 +- .../StepExecutionStartingProcessor.cs | 5 +- src/Processors/StepValidationProcessor.cs | 29 +++---- src/StepExecutor.cs | 5 +- src/dotnet.json | 2 +- test/ExecutionOrchestratorTests.cs | 41 +++++---- test/Extensions/MethodInfoExtensionTests.cs | 24 ------ test/Helpers/MockMethodBuilder.cs | 8 -- test/HookExecutorTests.cs | 15 ++-- test/Processors/ExecuteStepProcessorTests.cs | 23 +++-- .../ExecutionEndingProcessorTests.cs | 7 +- .../ExecutionStartingProcessorTests.cs | 7 +- .../ScenarioExecutionEndingProcessorTests.cs | 11 ++- ...ScenarioExecutionStartingProcessorTests.cs | 14 +-- .../SpecExecutionEndingProcessorTests.cs | 7 +- .../SpecExecutionStartingProcessorTests.cs | 7 +- .../StepExecutionEndingProcessorTests.cs | 7 +- .../StepExecutionStartingProcessorTests.cs | 9 +- test/StepExecutorTests.cs | 14 +-- test/StepRegistryTests.cs | 21 +---- test/ValidateProcessorTests.cs | 33 +------ 53 files changed, 219 insertions(+), 374 deletions(-) diff --git a/.gitignore b/.gitignore index 65e1bbc..8e63755 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/README.MD b/README.MD index 1e6a3f0..3e7d7ca 100644 --- a/README.MD +++ b/README.MD @@ -37,7 +37,7 @@ gauge run specs #### Install specific version ``` -gauge install dotnet --version 0.6.0 +gauge install dotnet --version 0.5.2 ``` #### Offline installation @@ -45,7 +45,7 @@ gauge install dotnet --version 0.6.0 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 diff --git a/_testdata/Sample/IntegrationTestSample.csproj b/_testdata/Sample/IntegrationTestSample.csproj index 5c822ae..5d0ca69 100644 --- a/_testdata/Sample/IntegrationTestSample.csproj +++ b/_testdata/Sample/IntegrationTestSample.csproj @@ -1,7 +1,7 @@ - net7.0 + net6.0 diff --git a/_testdata/Sample/StepImplementation.cs b/_testdata/Sample/StepImplementation.cs index bd6bdea..8d14cd1 100644 --- a/_testdata/Sample/StepImplementation.cs +++ b/_testdata/Sample/StepImplementation.cs @@ -30,14 +30,6 @@ public void SaySomething(string what, string who) GaugeMessages.WriteMessage("{0}, {1}!", what, who); } - [Step("Say to 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() { diff --git a/_testdata/Sample/gauge_bin/IntegrationTestSample.deps.json b/_testdata/Sample/gauge_bin/IntegrationTestSample.deps.json index 17b6981..6d92b42 100644 --- a/_testdata/Sample/gauge_bin/IntegrationTestSample.deps.json +++ b/_testdata/Sample/gauge_bin/IntegrationTestSample.deps.json @@ -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" diff --git a/_testdata/Sample/gauge_bin/IntegrationTestSample.dll b/_testdata/Sample/gauge_bin/IntegrationTestSample.dll index e565ba3e81286939c90161d7688df56b549625db..cb96ec35aabf2d2cf72a8c6f10ae1be3532c54c5 100644 GIT binary patch literal 8704 zcmeHMe~cXUb${QP-MRBRUZ3}jeVDU7=d;aWX-1^U>4%! z`WKV*y(K^H_`W#!+KS4FqeuRqBYScNlD_o=;XvDQN3MQ&pZ4sc3q|&o#&NSP6L;k5C)yt&CAyOH zii>^IC{Ew$B-*o*NJ#F72MOA;=>G<-Yc&x>yU2s>N>|$=)L!!XAk$-A$O?4l({QJ? zN2g&tVPl1l`C%l;&|M&jhro&%4>DYN#k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ZNaZ1 x&gO2_tbV;bwc#r=ext0hH9NAExMD5H9CRV>{6;b^-$Eua<16>!oc!-!{{t7o&sqQg diff --git a/_testdata/Sample/gauge_bin/IntegrationTestSample.pdb b/_testdata/Sample/gauge_bin/IntegrationTestSample.pdb index 2680ea0e507f46103f933255f0293c5f463d2e93..fa95a68b1fa86e141db61cde35b7f1262f25148d 100644 GIT binary patch literal 2492 zcmZ`(4NOy46u$SqwzLHVEEN2MC!mvx6~}&XIt40!22m;Cbj12-pHOZ4YTv6`V;G$^ z6Umr5-R3r#hRB@LZ2nB$pMlMvMa{NMMqG@WGn%;{hlXq})9B89rOjKjy}U2?eCOPI z?m6e4drPfzOEJQTehGjDb4uCO)65030%_2C5E=nF3mi>UcM0HSfVU!4sX}NhwOJ*f z)6*hwuz|(*lfGujHGZ-X-?m0k*tY^?R$bx}*!eyb3NepLVxGILLW4I=U$Hj1M4A(=| zBl{=9{_!z9LBW&2o*2VND0n&8li|c^M)afpQWSg=@R15m`^cc+>A+KCc$$JQ1-lWr zN>Q(L1*iLufp|2-_EO-P3Qpt6g830Uv@~KBJRbOX1*i6G1*i6j3QpsHB!*8?aJrvK z!D&47qt(HPW=rcsKcxo49j2Xt(MU{h6Gld&fw31e=nU=!-FZxV@)FriROm9f3i26z z6=VZbtYYNX0H#~4xie=K*=#Ps&bh<_Byr+O5&48Q^0R=FzRufpBE?YpLdTjB8(%$O z{Htl<>@#r}Q?^)9@BD7EXJ4(&e|qc5vZE*19jk8Cep-zzJ;g+*dV52`!2GJf_h@tl z=WpiC7HbRV^O~!jP395_o}DJY#1o8FErOd@ixSVdwO*gFg11XzLNi@4#UV%@Ueehl zUX&c1#A&RY+w0;}%GUCBzvL7=m4dKRG}}epRFsu#DlDG6kZm||Yw88Q^?1@p%i53S zl^;KNL-W?*&|`hueo~L=^E7-#PX;IJppgl5Fvw{Nd9*^#QpmXqIZq**6>?!%)>s3O zi#t9%K(?M$$+7vzv2XWI%z4R{q45meD>AcNcjhP4Bn+^*n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vwYJLBX_G8KU@_RRfx8&GiT+%^9PRbPUDg_6&@LXzlpx5 zRl`yw2X8@R_^71k;l**m+WRnQ<%hL(4(HwVZn!s?I`U*j6A4}b4pQV3l)eBJ3bC#O zZ)_4reo)ND)_rK(MP-$5Ip`KNZN5)|ag#G7f{ zsq1%u;|5@s@rHvfo95;C9h}`*o)-6k+?9ZLG2I9j{HTji@1CXZ2WZ%w3Ez*IuOH%> zW7Fr_jBgoXgrrcEAA<$QfX{{q`uw-}skFEDz(;q^-0?~;-j(@vT>!Z+?Ve?GQU(@6 zg-$k14xs9XYYJ_5-ubd|pnsJ>-tz2m}1uRNQn?g^8& zj3q&Tgw!doT;u`Aa{e~iJTD!O9iCGHvq~Sc3F7WlC34AidA@Wl`&o*I{e6!OyWX&D zPNeB65GtHf^3HZ{hKjp8FSKTanzQmcC`;@M9>gk8WHaw?|jJLw?RQXBPj?ZiQ zGuB*R8MwCK&3*;cpIIT^ZA^R*tLyEwjBwhP;ddrut8>W33)(P~A>x1pw(G#B zK{BBX&bb3Q=}pdBf3fRlo{yG2)-F?!1Yk;_XdRJUPV%xfsjgL@*oRyzCDo<{qCY{T zhF#-u)`<(d;aO2wC}nx6g%LF)VavxQcg?0M!U9m)0%CAXZc3AXZ8GUx^~a6sFX*+? z7A}0(H@T$;xw1{J{mSd1&s)}0-i}MU;+K73{b1L3#q)?Y6uz4$MAUp4Do?>f<0R%xtO zIZ3UOiR-8j^%?<$JE()NX`z+ihLepR)X~o#NcK}lk$J7Fl~r!~h-3sKWBh1UkCfi}2~f!BHqoZ { "foorow1", "barrow1" }); table.AddRow(new List { "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(); @@ -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(); @@ -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(); @@ -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")); @@ -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(); @@ -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); @@ -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(); @@ -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", diff --git a/integration-test/ExternalReferenceTests.cs b/integration-test/ExternalReferenceTests.cs index d20d5ab..d7df069 100644 --- a/integration-test/ExternalReferenceTests.cs +++ b/integration-test/ExternalReferenceTests.cs @@ -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; @@ -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(); @@ -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); diff --git a/integration-test/ImplementCodeProcessorTests.cs b/integration-test/ImplementCodeProcessorTests.cs index 3a33018..3d2b7a5 100644 --- a/integration-test/ImplementCodeProcessorTests.cs +++ b/integration-test/ImplementCodeProcessorTests.cs @@ -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] diff --git a/src/ExecutableRunnerServiceHandler.cs b/src/ExecutableRunnerServiceHandler.cs index 5319ddd..830d519 100644 --- a/src/ExecutableRunnerServiceHandler.cs +++ b/src/ExecutableRunnerServiceHandler.cs @@ -38,54 +38,54 @@ public ExecutableRunnerServiceHandler(IActivatorWrapper activationWrapper, IRefl IAssemblyLoader assemblyLoader, IStaticLoader loader, ExecutorPool pool, IHostApplicationLifetime lifetime) : base(loader, pool, lifetime) { - _activatorWrapper = activationWrapper; - _reflectionWrapper = reflectionWrapper; - _assemblyLoader = assemblyLoader; + this._activatorWrapper = activationWrapper; + this._reflectionWrapper = reflectionWrapper; + this._assemblyLoader = assemblyLoader; _stepRegistry = assemblyLoader.GetStepRegistry(); InitializeExecutionMessageHandlers(); } public override Task InitializeSuiteDataStore(SuiteDataStoreInitRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), () => suiteDataStoreInitProcessor.Process()); + return _pool.Execute(getStream(request.Stream), () => this.suiteDataStoreInitProcessor.Process()); } public override Task ExecuteStep(ExecuteStepRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await executeStepProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.executeStepProcessor.Process(request)); } public override Task FinishExecution(ExecutionEndingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await executionEndingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.executionEndingProcessor.Process(request)); } public override Task FinishScenarioExecution(ScenarioExecutionEndingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await scenarioExecutionEndingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.scenarioExecutionEndingProcessor.Process(request)); } public override Task FinishSpecExecution(SpecExecutionEndingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await specExecutionEndingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.specExecutionEndingProcessor.Process(request)); } public override Task FinishStepExecution(StepExecutionEndingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await stepExecutionEndingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.stepExecutionEndingProcessor.Process(request)); } public override Task InitializeScenarioDataStore(ScenarioDataStoreInitRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), () => scenarioDataStoreInitProcessor.Process()); + return _pool.Execute(getStream(request.Stream), () => this.scenarioDataStoreInitProcessor.Process()); } public override Task InitializeSpecDataStore(SpecDataStoreInitRequest request, ServerCallContext context) { try { - return _pool.Execute(GetStream(request.Stream), () => specDataStoreInitProcessor.Process()); + return _pool.Execute(getStream(request.Stream), () => this.specDataStoreInitProcessor.Process()); } - catch (Exception e) + catch (System.Exception e) { Console.WriteLine(e); Environment.Exit(1); @@ -95,51 +95,58 @@ public override Task InitializeSpecDataStore(SpecDataSt public override Task StartExecution(ExecutionStartingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await executionStartingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.executionStartingProcessor.Process(request)); } public override Task StartScenarioExecution(ScenarioExecutionStartingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await scenarioExecutionStartingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.scenarioExecutionStartingProcessor.Process(request)); } public override Task StartSpecExecution(SpecExecutionStartingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await specExecutionStartingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.specExecutionStartingProcessor.Process(request)); } public override Task StartStepExecution(StepExecutionStartingRequest request, ServerCallContext context) { - return _pool.Execute(GetStream(request.Stream), async () => await stepExecutionStartingProcessor.Process(request)); + return _pool.Execute(getStream(request.Stream), () => this.stepExecutionStartingProcessor.Process(request)); } private void InitializeExecutionMessageHandlers() { - var tableFormatter = new TableFormatter(_assemblyLoader, _activatorWrapper); - var classInstanceManager = new ThreadLocal(() => _assemblyLoader.GetClassInstanceManager()); - var executionInfoMapper = new ExecutionInfoMapper(_assemblyLoader, _activatorWrapper); - var executionOrchestrator = new ExecutionOrchestrator(_reflectionWrapper, _assemblyLoader, + var tableFormatter = new TableFormatter(this._assemblyLoader, this._activatorWrapper); + var classInstanceManager = new ThreadLocal(() => + { + return this._assemblyLoader.GetClassInstanceManager(); + }); + var executionInfoMapper = new ExecutionInfoMapper(this._assemblyLoader, this._activatorWrapper); + var executionOrchestrator = new ExecutionOrchestrator(this._reflectionWrapper, this._assemblyLoader, classInstanceManager.Value, - new HookExecutor(_assemblyLoader, _reflectionWrapper, classInstanceManager.Value, executionInfoMapper), - new StepExecutor(_assemblyLoader, _reflectionWrapper, classInstanceManager.Value)); - - executionStartingProcessor = new ExecutionStartingProcessor(executionOrchestrator); - executionEndingProcessor = new ExecutionEndingProcessor(executionOrchestrator); - specExecutionStartingProcessor = new SpecExecutionStartingProcessor(executionOrchestrator); - specExecutionEndingProcessor = new SpecExecutionEndingProcessor(executionOrchestrator); - scenarioExecutionStartingProcessor = new ScenarioExecutionStartingProcessor(executionOrchestrator); - scenarioExecutionEndingProcessor = new ScenarioExecutionEndingProcessor(executionOrchestrator); - stepExecutionStartingProcessor = new StepExecutionStartingProcessor(executionOrchestrator); - stepExecutionEndingProcessor = new StepExecutionEndingProcessor(executionOrchestrator); - executeStepProcessor = new ExecuteStepProcessor(_stepRegistry, executionOrchestrator, tableFormatter); - scenarioDataStoreInitProcessor = new ScenarioDataStoreInitProcessor(_assemblyLoader); - specDataStoreInitProcessor = new SpecDataStoreInitProcessor(_assemblyLoader); - suiteDataStoreInitProcessor = new SuiteDataStoreInitProcessor(_assemblyLoader); + 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); } - private int GetStream(int stream) + private int getStream(int stream) { - return _pool.IsMultithreading ? Math.Max(stream, 1) : 1; + if (!_pool.IsMultithreading) + { + return 1; + } + return Math.Max(stream, 1); } } } \ No newline at end of file diff --git a/src/ExecutionOrchestrator.cs b/src/ExecutionOrchestrator.cs index f8f3123..f748ce6 100644 --- a/src/ExecutionOrchestrator.cs +++ b/src/ExecutionOrchestrator.cs @@ -9,7 +9,6 @@ using System.Diagnostics; using System.Linq; using System.Reflection; -using System.Threading.Tasks; using Gauge.CSharp.Core; using Gauge.Dotnet.Models; using Gauge.Dotnet.Strategy; @@ -39,11 +38,11 @@ public ExecutionOrchestrator(IReflectionWrapper reflectionWrapper, IAssemblyLoad [DebuggerHidden] - public async Task ExecuteStep(GaugeMethod method, params string[] args) + public ProtoExecutionResult ExecuteStep(GaugeMethod method, params string[] args) { var stopwatch = Stopwatch.StartNew(); - var executionResult = await _stepExecutor.Execute(method, args); + var executionResult = _stepExecutor.Execute(method, args); return BuildResult(stopwatch, executionResult); } @@ -80,12 +79,11 @@ public IEnumerable GetAllPendingScreenshotFiles() } [DebuggerHidden] - public async Task ExecuteHooks(string hookType, HooksStrategy strategy, - IList applicableTags, + public ProtoExecutionResult ExecuteHooks(string hookType, HooksStrategy strategy, IList applicableTags, ExecutionInfo info) { var stopwatch = Stopwatch.StartNew(); - var executionResult = await _hookExecutor.Execute(hookType, strategy, applicableTags, info); + var executionResult = _hookExecutor.Execute(hookType, strategy, applicableTags, info); return BuildResult(stopwatch, executionResult); } diff --git a/src/Executor/ExecutorPool.cs b/src/Executor/ExecutorPool.cs index 058ee66..df7751b 100644 --- a/src/Executor/ExecutorPool.cs +++ b/src/Executor/ExecutorPool.cs @@ -14,16 +14,16 @@ namespace Gauge.Dotnet.Executor public class ExecutorPool : IDisposable { public bool IsMultithreading { get; internal set; } - private ConcurrentDictionary _workers = new ConcurrentDictionary(); - + private ConcurrentDictionary _workers = new ConcurrentDictionary(); + public ExecutorPool(int size, bool isMultithreading) { for (int i = 1; i <= size; i++) { - bool added = _workers.TryAdd(GetName(i), new TaskFactory(CancellationToken.None, TaskCreationOptions.None, TaskContinuationOptions.None, new CustomTaskScheduler())); + bool added = _workers.TryAdd(GetName(i), new CustomTaskScheduler()); if (!added) { - Logger.Fatal("Failed to add Worker for stream " + i); + Logger.Fatal("Failed to add Wroker for stream " + i); } } @@ -34,25 +34,16 @@ public void Dispose() { foreach (var w in _workers) { - ((CustomTaskScheduler)w.Value.Scheduler)?.Dispose(); + w.Value.Dispose(); } } public Task Execute(int stream, Func fn) { - bool found = _workers.TryGetValue(GetName(stream), out TaskFactory taskFactory); - if (found) - { - return taskFactory.StartNew(fn); - } - throw new StreamNotFountException(stream); - } - public Task Execute(int stream, Func> fn) - { - bool found = _workers.TryGetValue(GetName(stream), out TaskFactory taskFactory); + bool found = _workers.TryGetValue(GetName(stream), out CustomTaskScheduler scheduler); if (found) { - return taskFactory.StartNew(fn).Unwrap(); + return Task.Factory.StartNew(fn, new CancellationToken(), TaskCreationOptions.None, scheduler); } throw new StreamNotFountException(stream); } diff --git a/src/Extensions/MethodInfoExtensions.cs b/src/Extensions/MethodInfoExtensions.cs index c83252d..eebaebe 100644 --- a/src/Extensions/MethodInfoExtensions.cs +++ b/src/Extensions/MethodInfoExtensions.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; namespace Gauge.Dotnet.Extensions { @@ -35,10 +34,5 @@ public static bool IsRecoverableStep(this MethodInfo info, IAssemblyLoader assem return customAttributes.Any(stepType.IsInstanceOfType) && customAttributes.Any(continueOnFailureType.IsInstanceOfType); } - - public static bool IsAsyncVoid(this MethodInfo info) - { - return info.GetCustomAttributes(typeof(AsyncStateMachineAttribute),true).Any() && info.ReturnType == typeof(void); - } } } \ No newline at end of file diff --git a/src/Gauge.Dotnet.csproj b/src/Gauge.Dotnet.csproj index 990a3fe..7fdfefd 100644 --- a/src/Gauge.Dotnet.csproj +++ b/src/Gauge.Dotnet.csproj @@ -5,7 +5,7 @@ net6.0;net7.0;net8.0 Runner.NetCore30 The Gauge Team - 0.6.0 + 0.5.3 ThoughtWorks Inc. Gauge C# runner for Gauge. https://gauge.org diff --git a/src/HookExecutor.cs b/src/HookExecutor.cs index b5aea9c..b391ee0 100644 --- a/src/HookExecutor.cs +++ b/src/HookExecutor.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Strategy; using Gauge.Dotnet.Wrappers; @@ -32,7 +31,7 @@ public HookExecutor(IAssemblyLoader assemblyLoader, IReflectionWrapper reflectio _executionInfoMapper = mapper; } - public async Task Execute(string hookType, IHooksStrategy strategy, IList applicableTags, + public ExecutionResult Execute(string hookType, IHooksStrategy strategy, IList applicableTags, ExecutionInfo info) { var methods = GetHookMethods(hookType, strategy, applicableTags); @@ -46,7 +45,7 @@ public async Task Execute(string hookType, IHooksStrategy strat try { var context = _executionInfoMapper.ExecutionContextFrom(info); - await ExecuteHook(methodInfo, context); + ExecuteHook(methodInfo, context); } catch (Exception ex) { @@ -62,12 +61,12 @@ public async Task Execute(string hookType, IHooksStrategy strat return executionResult; } - private async Task ExecuteHook(MethodInfo method, params object[] objects) + private void ExecuteHook(MethodInfo method, params object[] objects) { if (HasArguments(method, objects)) - await Execute(method, objects); + Execute(method, objects); else - await Execute(method); + Execute(method); } diff --git a/src/IExecutionOrchestrator.cs b/src/IExecutionOrchestrator.cs index 403d450..e67f516 100644 --- a/src/IExecutionOrchestrator.cs +++ b/src/IExecutionOrchestrator.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Strategy; using Gauge.Messages; @@ -15,9 +14,9 @@ namespace Gauge.Dotnet { public interface IExecutionOrchestrator { - Task ExecuteStep(GaugeMethod method, params string[] args); + ProtoExecutionResult ExecuteStep(GaugeMethod method, params string[] args); - Task ExecuteHooks(string hookType, HooksStrategy strategy, IList applicableTags, + ProtoExecutionResult ExecuteHooks(string hookType, HooksStrategy strategy, IList applicableTags, ExecutionInfo context); void ClearCache(); diff --git a/src/IHookExecutor.cs b/src/IHookExecutor.cs index 0175188..90a7acf 100644 --- a/src/IHookExecutor.cs +++ b/src/IHookExecutor.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; -using System.Threading.Tasks; using Gauge.Messages; using Gauge.Dotnet.Models; using Gauge.Dotnet.Strategy; @@ -15,7 +14,7 @@ namespace Gauge.Dotnet { public interface IHookExecutor { - Task Execute(string hookType, IHooksStrategy strategy, IList applicableTags, + ExecutionResult Execute(string hookType, IHooksStrategy strategy, IList applicableTags, ExecutionInfo context); } } \ No newline at end of file diff --git a/src/IStepExecutor.cs b/src/IStepExecutor.cs index cc704f4..334073c 100644 --- a/src/IStepExecutor.cs +++ b/src/IStepExecutor.cs @@ -5,13 +5,12 @@ *----------------------------------------------------------------*/ -using System.Threading.Tasks; using Gauge.Dotnet.Models; namespace Gauge.Dotnet { public interface IStepExecutor { - Task Execute(GaugeMethod gaugeMethod, string[] args); + ExecutionResult Execute(GaugeMethod gaugeMethod, string[] args); } } \ No newline at end of file diff --git a/src/MethodExecutor.cs b/src/MethodExecutor.cs index 2d2a8c4..c74dc71 100644 --- a/src/MethodExecutor.cs +++ b/src/MethodExecutor.cs @@ -6,10 +6,7 @@ using System; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; using Gauge.Dotnet.Wrappers; namespace Gauge.Dotnet @@ -29,7 +26,7 @@ protected MethodExecutor(Type type, _classInstanceManager = classInstanceManager; } - protected Task Execute(MethodInfo method, params object[] parameters) + protected void Execute(MethodInfo method, params object[] parameters) { var typeToLoad = method.DeclaringType; var instance = @@ -41,12 +38,7 @@ protected Task Execute(MethodInfo method, params object[] parameters) throw new TypeLoadException(error); } - if (method.GetCustomAttributes(typeof(AsyncStateMachineAttribute), false).Any()) - { - return (Task)_reflectionWrapper.Invoke(method, instance, parameters); - } - - return Task.Run(() => _reflectionWrapper.Invoke(method, instance, parameters)); + _reflectionWrapper.Invoke(method, instance, parameters); } } } \ No newline at end of file diff --git a/src/Models/GaugeMethod.cs b/src/Models/GaugeMethod.cs index 592cd52..c70a505 100644 --- a/src/Models/GaugeMethod.cs +++ b/src/Models/GaugeMethod.cs @@ -26,6 +26,6 @@ public class GaugeMethod public FileLinePositionSpan Span { get; internal set; } public bool HasAlias { get; set; } public IEnumerable Aliases { get; set; } - public bool IsExternal {get; set;} + public bool IsExternal {get; set;} } } \ No newline at end of file diff --git a/src/Models/IStepRegistry.cs b/src/Models/IStepRegistry.cs index 96739a2..804ae2b 100644 --- a/src/Models/IStepRegistry.cs +++ b/src/Models/IStepRegistry.cs @@ -21,6 +21,5 @@ public interface IStepRegistry void RemoveSteps(string filepath); IEnumerable GetStepPositions(string filePath); bool IsFileCached(string file); - bool HasAsyncVoidImplementation(string parsedStepText); } } \ No newline at end of file diff --git a/src/Models/StepRegistry.cs b/src/Models/StepRegistry.cs index b74f84b..eca789b 100644 --- a/src/Models/StepRegistry.cs +++ b/src/Models/StepRegistry.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Gauge.Dotnet.Extensions; using Gauge.Messages; using static Gauge.Messages.StepPositionsResponse.Types; @@ -120,10 +119,5 @@ public bool IsFileCached(string file) } return false; } - - public bool HasAsyncVoidImplementation(string parsedStepText) - { - return !ContainsStep(parsedStepText) || _registry[parsedStepText].Any(x => x.MethodInfo.IsAsyncVoid()); - } } } \ No newline at end of file diff --git a/src/Processors/ExecuteStepProcessor.cs b/src/Processors/ExecuteStepProcessor.cs index bc30d74..e6b37eb 100644 --- a/src/Processors/ExecuteStepProcessor.cs +++ b/src/Processors/ExecuteStepProcessor.cs @@ -7,7 +7,6 @@ using System.Diagnostics; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Messages; @@ -28,7 +27,7 @@ public ExecuteStepProcessor(IStepRegistry registry, IExecutionOrchestrator execu } [DebuggerHidden] - public async Task Process(ExecuteStepRequest request) + public ExecutionStatusResponse Process(ExecuteStepRequest request) { if (!_stepRegistry.ContainsStep(request.ParsedStepText)) return ExecutionError("Step Implementation not found"); @@ -54,7 +53,7 @@ public async Task Process(ExecuteStepRequest request) args[i] = validTableParamTypes.Contains(stepParameter[i].ParameterType) ? _tableFormatter.GetJSON(stepParameter[i].Table) : stepParameter[i].Value; - var protoExecutionResult = await _executionOrchestrator.ExecuteStep(method, args); + var protoExecutionResult = _executionOrchestrator.ExecuteStep(method, args); return new ExecutionStatusResponse { ExecutionResult = protoExecutionResult }; } diff --git a/src/Processors/ExecutionEndingProcessor.cs b/src/Processors/ExecutionEndingProcessor.cs index a283e64..c8a055d 100644 --- a/src/Processors/ExecutionEndingProcessor.cs +++ b/src/Processors/ExecutionEndingProcessor.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -21,9 +20,9 @@ public ExecutionEndingProcessor(IExecutionOrchestrator executionOrchestrator) } [DebuggerHidden] - public virtual async Task Process(ExecutionEndingRequest request) + public virtual ExecutionStatusResponse Process(ExecutionEndingRequest request) { - var result = await ExecuteHooks(request.CurrentExecutionInfo); + var result = ExecuteHooks(request.CurrentExecutionInfo); ClearCacheForConfiguredLevel(); return result; } diff --git a/src/Processors/ExecutionStartingProcessor.cs b/src/Processors/ExecutionStartingProcessor.cs index d57d417..82650e8 100644 --- a/src/Processors/ExecutionStartingProcessor.cs +++ b/src/Processors/ExecutionStartingProcessor.cs @@ -8,7 +8,6 @@ using System; using System.Diagnostics; using System.Threading; -using System.Threading.Tasks; using Gauge.CSharp.Core; using Gauge.Messages; @@ -25,7 +24,7 @@ public ExecutionStartingProcessor(IExecutionOrchestrator executionOrchestrator) [DebuggerHidden] - public virtual async Task Process(ExecutionStartingRequest request) + public virtual ExecutionStatusResponse Process(ExecutionStartingRequest request) { var debuggingEnv = Utils.TryReadEnvValue("DEBUGGING"); if (debuggingEnv != null && debuggingEnv.ToLower().Equals("true")) @@ -44,7 +43,7 @@ public virtual async Task Process(ExecutionStartingRequ break; } } - return await ExecuteHooks(request.CurrentExecutionInfo); + return ExecuteHooks(request.CurrentExecutionInfo); } diff --git a/src/Processors/HookExecutionProcessor.cs b/src/Processors/HookExecutionProcessor.cs index 56481bd..9c8e3d4 100644 --- a/src/Processors/HookExecutionProcessor.cs +++ b/src/Processors/HookExecutionProcessor.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.CSharp.Core; using Gauge.Dotnet.Strategy; using Gauge.Messages; @@ -34,11 +33,11 @@ protected HookExecutionProcessor(IExecutionOrchestrator executionOrchestrator) protected virtual string CacheClearLevel => null; - protected virtual async Task ExecuteHooks(ExecutionInfo info) + protected virtual ExecutionStatusResponse ExecuteHooks(ExecutionInfo info) { var applicableTags = GetApplicableTags(info); var protoExecutionResult = - await ExecutionOrchestrator.ExecuteHooks(HookType, Strategy, applicableTags, info); + ExecutionOrchestrator.ExecuteHooks(HookType, Strategy, applicableTags, info); var allPendingMessages = ExecutionOrchestrator.GetAllPendingMessages().Where(m => m != null); var allPendingScreenShotFiles = ExecutionOrchestrator.GetAllPendingScreenshotFiles(); protoExecutionResult.Message.AddRange(allPendingMessages); diff --git a/src/Processors/ScenarioExecutionEndingProcessor.cs b/src/Processors/ScenarioExecutionEndingProcessor.cs index 508f27f..93eaaf0 100644 --- a/src/Processors/ScenarioExecutionEndingProcessor.cs +++ b/src/Processors/ScenarioExecutionEndingProcessor.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -27,10 +26,10 @@ public ScenarioExecutionEndingProcessor(IExecutionOrchestrator executionOrchestr protected override string CacheClearLevel => ScenarioLevel; - public async Task Process(ScenarioExecutionEndingRequest request) + public ExecutionStatusResponse Process(ScenarioExecutionEndingRequest request) { _executionOrchestrator.CloseExecutionScope(); - var result = await ExecuteHooks(request.CurrentExecutionInfo); + var result = ExecuteHooks(request.CurrentExecutionInfo); ClearCacheForConfiguredLevel(); return result; } diff --git a/src/Processors/ScenarioExecutionStartingProcessor.cs b/src/Processors/ScenarioExecutionStartingProcessor.cs index e135da7..406b53b 100644 --- a/src/Processors/ScenarioExecutionStartingProcessor.cs +++ b/src/Processors/ScenarioExecutionStartingProcessor.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -24,10 +23,10 @@ public ScenarioExecutionStartingProcessor(IExecutionOrchestrator executionOrches protected override string HookType => "BeforeScenario"; - public async Task Process(ScenarioExecutionStartingRequest request) + public ExecutionStatusResponse Process(ScenarioExecutionStartingRequest request) { _executionOrchestrator.StartExecutionScope("scenario"); - return await ExecuteHooks(request.CurrentExecutionInfo); + return ExecuteHooks(request.CurrentExecutionInfo); } protected override List GetApplicableTags(ExecutionInfo info) diff --git a/src/Processors/SpecExecutionEndingProcessor.cs b/src/Processors/SpecExecutionEndingProcessor.cs index f81cf79..b376d86 100644 --- a/src/Processors/SpecExecutionEndingProcessor.cs +++ b/src/Processors/SpecExecutionEndingProcessor.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -30,10 +29,10 @@ protected override List GetApplicableTags(ExecutionInfo info) return info.CurrentSpec.Tags.ToList(); } - public async Task Process(SpecExecutionEndingRequest request) + public ExecutionStatusResponse Process(SpecExecutionEndingRequest request) { _executionOrchestrator.CloseExecutionScope(); - var result = await ExecuteHooks(request.CurrentExecutionInfo); + var result = ExecuteHooks(request.CurrentExecutionInfo); ClearCacheForConfiguredLevel(); return result; } diff --git a/src/Processors/SpecExecutionStartingProcessor.cs b/src/Processors/SpecExecutionStartingProcessor.cs index 65c1091..e3889f7 100644 --- a/src/Processors/SpecExecutionStartingProcessor.cs +++ b/src/Processors/SpecExecutionStartingProcessor.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -28,10 +27,10 @@ protected override List GetApplicableTags(ExecutionInfo info) return info.CurrentSpec.Tags.ToList(); } - public async Task Process(SpecExecutionStartingRequest request) + public ExecutionStatusResponse Process(SpecExecutionStartingRequest request) { _executionOrchestrator.StartExecutionScope("spec"); - return await ExecuteHooks(request.CurrentExecutionInfo); + return ExecuteHooks(request.CurrentExecutionInfo); } } } \ No newline at end of file diff --git a/src/Processors/StepExecutionEndingProcessor.cs b/src/Processors/StepExecutionEndingProcessor.cs index 89b14e8..fe19c36 100644 --- a/src/Processors/StepExecutionEndingProcessor.cs +++ b/src/Processors/StepExecutionEndingProcessor.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -21,9 +20,9 @@ public StepExecutionEndingProcessor(IExecutionOrchestrator executionOrchestrator protected override string HookType => "AfterStep"; - public async Task Process(StepExecutionEndingRequest request) + public ExecutionStatusResponse Process(StepExecutionEndingRequest request) { - return await base.ExecuteHooks(request.CurrentExecutionInfo); + return base.ExecuteHooks(request.CurrentExecutionInfo); } protected override List GetApplicableTags(ExecutionInfo info) diff --git a/src/Processors/StepExecutionStartingProcessor.cs b/src/Processors/StepExecutionStartingProcessor.cs index 66b1bfb..89d6906 100644 --- a/src/Processors/StepExecutionStartingProcessor.cs +++ b/src/Processors/StepExecutionStartingProcessor.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Messages; namespace Gauge.Dotnet.Processors @@ -21,9 +20,9 @@ public StepExecutionStartingProcessor(IExecutionOrchestrator executionOrchestrat protected override string HookType => "BeforeStep"; - public async Task Process(StepExecutionStartingRequest request) + public ExecutionStatusResponse Process(StepExecutionStartingRequest request) { - return await ExecuteHooks(request.CurrentExecutionInfo); + return ExecuteHooks(request.CurrentExecutionInfo); } protected override List GetApplicableTags(ExecutionInfo info) diff --git a/src/Processors/StepValidationProcessor.cs b/src/Processors/StepValidationProcessor.cs index 3f38193..d934378 100644 --- a/src/Processors/StepValidationProcessor.cs +++ b/src/Processors/StepValidationProcessor.cs @@ -24,25 +24,24 @@ public StepValidationProcessor(IStepRegistry stepRegistry) public StepValidateResponse Process(StepValidateRequest request) { - if (!_stepRegistry.ContainsStep(request.StepText)) + var stepToValidate = request.StepText; + var isValid = true; + var errorMessage = ""; + var suggestion = ""; + var errorType = StepValidateResponse.Types.ErrorType.StepImplementationNotFound; + if (!_stepRegistry.ContainsStep(stepToValidate)) { - return GetStepValidateResponseMessage(false, StepValidateResponse.Types.ErrorType.StepImplementationNotFound, - $"No implementation found for : {request.StepText}. Full Step Text :", GetSuggestion(request.StepValue)); + isValid = false; + errorMessage = string.Format("No implementation found for : {0}. Full Step Text :", stepToValidate); + suggestion = GetSuggestion(request.StepValue); } - - if (_stepRegistry.HasMultipleImplementations(request.StepText)) + else if (_stepRegistry.HasMultipleImplementations(stepToValidate)) { - return GetStepValidateResponseMessage(false, StepValidateResponse.Types.ErrorType.DuplicateStepImplementation, - $"Multiple step implementations found for : {request.StepText}", string.Empty); + isValid = false; + errorType = StepValidateResponse.Types.ErrorType.DuplicateStepImplementation; + errorMessage = string.Format("Multiple step implementations found for : {0}", stepToValidate); } - - if (_stepRegistry.HasAsyncVoidImplementation(request.StepText)) - { - return GetStepValidateResponseMessage(false, StepValidateResponse.Types.ErrorType.StepImplementationNotFound, - string.Empty, $"Found a potential step implementation with 'async void' return for : {request.StepText}. Usage of 'async void' is discouraged (https://learn.microsoft.com/en-us/archive/msdn-magazine/2013/march/async-await-best-practices-in-asynchronous-programming#avoid-async-void). Use `async Task` instead."); - } - return GetStepValidateResponseMessage(true, - StepValidateResponse.Types.ErrorType.StepImplementationNotFound, string.Empty, string.Empty); + return GetStepValidateResponseMessage(isValid, errorType, errorMessage, suggestion); } private string GetSuggestion(ProtoStepValue stepValue) diff --git a/src/StepExecutor.cs b/src/StepExecutor.cs index 07b7901..98f99e2 100644 --- a/src/StepExecutor.cs +++ b/src/StepExecutor.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Runtime.Serialization.Json; using System.Text; -using System.Threading.Tasks; using Gauge.Dotnet.Converters; using Gauge.Dotnet.Models; using Gauge.Dotnet.Wrappers; @@ -29,7 +28,7 @@ public StepExecutor(IAssemblyLoader assemblyLoader, IReflectionWrapper reflectio _assemblyLoader = assemblyLoader; } - public async Task Execute(GaugeMethod gaugeMethod, params string[] args) + public ExecutionResult Execute(GaugeMethod gaugeMethod, params string[] args) { { var method = gaugeMethod.MethodInfo; @@ -48,7 +47,7 @@ public async Task Execute(GaugeMethod gaugeMethod, params strin } }).ToArray(); Logger.Debug($"Executing method: {gaugeMethod.Name}"); - await base.Execute(method, StringParamConverter.TryConvertParams(method, parameters)); + Execute(method, StringParamConverter.TryConvertParams(method, parameters)); executionResult.Success = true; } catch (Exception ex) diff --git a/src/dotnet.json b/src/dotnet.json index 085707d..b2c6614 100644 --- a/src/dotnet.json +++ b/src/dotnet.json @@ -1,6 +1,6 @@ { "id": "dotnet", - "version": "0.6.0", + "version": "0.5.3", "description": "C# support for gauge + .NET 6.0/7.0/8.0", "run": { "windows": [ diff --git a/test/ExecutionOrchestratorTests.cs b/test/ExecutionOrchestratorTests.cs index 4a83bf2..eadaaf2 100644 --- a/test/ExecutionOrchestratorTests.cs +++ b/test/ExecutionOrchestratorTests.cs @@ -10,7 +10,6 @@ using System.IO; using System.Reflection; using System.Threading; -using System.Threading.Tasks; using Gauge.CSharp.Core; using Gauge.Dotnet.Models; using Gauge.Dotnet.Strategy; @@ -39,7 +38,7 @@ public void TearDown() } [Test] - public async Task ShouldExecuteHooks() + public void ShouldExecuteHooks() { var pendingMessages = new List { "Foo", "Bar" }; var pendingScreenshots = new List { "screenshot.png" }; @@ -48,11 +47,11 @@ public async Task ShouldExecuteHooks() var mockAssemblyLoader = new Mock(); var mockClassInstanceManager = new Mock().Object; var hooksStrategy = new HooksStrategy(); - var mockHookExecutor = new Mock(); - mockHookExecutor.Setup(m => + var mockHookExecuter = new Mock(); + mockHookExecuter.Setup(m => m.Execute("hooks", hooksStrategy, new List(), It.IsAny()) - ).Returns(Task.FromResult(executionResult)).Verifiable(); - var mockStepExecutor = new Mock(); + ).Returns(executionResult).Verifiable(); + var mockStepExecuter = new Mock(); var reflectionWrapper = mockReflectionWrapper.Object; var mockType = new Mock().Object; mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)).Returns(mockType); @@ -65,17 +64,17 @@ public async Task ShouldExecuteHooks() .Returns(pendingScreenshots); var assemblyLoader = mockAssemblyLoader.Object; var executionOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, - mockClassInstanceManager, mockHookExecutor.Object, mockStepExecutor.Object); + mockClassInstanceManager, mockHookExecuter.Object, mockStepExecuter.Object); - var result = await executionOrchestrator.ExecuteHooks("hooks", hooksStrategy, new List(), + var result = executionOrchestrator.ExecuteHooks("hooks", hooksStrategy, new List(), It.IsAny()); - mockHookExecutor.VerifyAll(); + mockHookExecuter.VerifyAll(); ClassicAssert.False(result.Failed); } [Test] - public async Task ShouldExecuteHooksAndNotTakeScreenshotOnFailureWhenDisabled() + public void ShouldExecuteHooksAndNotTakeScreenshotOnFailureWhenDisabled() { var pendingMessages = new List { "Foo", "Bar" }; var pendingScreenshots = new List { "screenshot.png" }; @@ -98,7 +97,7 @@ public async Task ShouldExecuteHooksAndNotTakeScreenshotOnFailureWhenDisabled() mockHookExecuter.Object, mockStepExecuter.Object); mockHookExecuter.Setup(executor => executor.Execute("hooks", hooksStrategy, new List(), It.IsAny()) - ).Returns(Task.FromResult(executionResult)).Verifiable(); + ).Returns(executionResult).Verifiable(); var mockType = new Mock().Object; mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)).Returns(mockType); mockAssemblyLoader.Setup(x => x.GetLibType(LibType.ScreenshotFilesCollector)).Returns(mockType); @@ -112,7 +111,7 @@ public async Task ShouldExecuteHooksAndNotTakeScreenshotOnFailureWhenDisabled() var screenshotEnabled = Utils.TryReadEnvValue("SCREENSHOT_ON_FAILURE"); Environment.SetEnvironmentVariable("SCREENSHOT_ON_FAILURE", "false"); - var result = await orchestrator.ExecuteHooks("hooks", hooksStrategy, new List(), + var result = orchestrator.ExecuteHooks("hooks", hooksStrategy, new List(), It.IsAny()); mockHookExecuter.VerifyAll(); @@ -122,7 +121,7 @@ public async Task ShouldExecuteHooksAndNotTakeScreenshotOnFailureWhenDisabled() } [Test] - public async Task ShouldExecuteMethod() + public void ShouldExecuteMethod() { var pendingMessages = new List { "Foo", "Bar" }; var pendingScreenshots = new List { "screenshot.png" }; @@ -136,7 +135,7 @@ public async Task ShouldExecuteMethod() var mockStepExecutor = new Mock(); mockStepExecutor.Setup(executor => executor.Execute(gaugeMethod, It.IsAny())) - .Returns(() => Task.FromResult(new ExecutionResult { Success = true })) + .Returns(() => new ExecutionResult { Success = true }) .Callback(() => Thread.Sleep(1)); // Simulate a delay in method execution var orchestrator = new ExecutionOrchestrator(mockReflectionWrapper.Object, mockAssemblyLoader.Object, @@ -151,14 +150,14 @@ public async Task ShouldExecuteMethod() mockReflectionWrapper.Setup(x => x.InvokeMethod(mockType, null, "GetAllPendingScreenshotFiles", It.IsAny())) .Returns(pendingScreenshots); - var result = await orchestrator.ExecuteStep(gaugeMethod, args); + var result = orchestrator.ExecuteStep(gaugeMethod, args); mockStepExecutor.VerifyAll(); ClassicAssert.False(result.Failed); ClassicAssert.True(result.ExecutionTime > 0); } [Test] - public async Task ShouldNotTakeScreenShotWhenDisabled() + public void ShouldNotTakeScreenShotWhenDisabled() { var pendingMessages = new List { "Foo", "Bar" }; var pendingScreenshots = new List { "screenshot.png" }; @@ -176,7 +175,7 @@ public async Task ShouldNotTakeScreenShotWhenDisabled() var mockHookExecuter = new Mock(); var mockStepExecutor = new Mock(); mockStepExecutor.Setup(executor => executor.Execute(gaugeMethod, It.IsAny())) - .Returns(Task.FromResult(executionResult)); + .Returns(executionResult); var mockType = new Mock().Object; mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)).Returns(mockType); mockAssemblyLoader.Setup(x => x.GetLibType(LibType.ScreenshotFilesCollector)).Returns(mockType); @@ -193,7 +192,7 @@ public async Task ShouldNotTakeScreenShotWhenDisabled() var screenshotEnabled = Utils.TryReadEnvValue("SCREENSHOT_ON_FAILURE"); Environment.SetEnvironmentVariable("SCREENSHOT_ON_FAILURE", "false"); - var result = await orchestrator.ExecuteStep(gaugeMethod, "Bar", "string"); + var result = orchestrator.ExecuteStep(gaugeMethod, "Bar", "string"); mockStepExecutor.VerifyAll(); ClassicAssert.True(string.IsNullOrEmpty(result.FailureScreenshotFile)); @@ -201,7 +200,7 @@ public async Task ShouldNotTakeScreenShotWhenDisabled() } [Test] - public async Task ShouldTakeScreenShotOnFailedExecution() + public void ShouldTakeScreenShotOnFailedExecution() { var pendingMessages = new List { "Foo", "Bar" }; var expectedScreenshot = "Testscreenshot.png"; @@ -219,7 +218,7 @@ public async Task ShouldTakeScreenShotOnFailedExecution() var mockHookExecuter = new Mock(); var mockStepExecutor = new Mock(); mockStepExecutor.Setup(executor => executor.Execute(gaugeMethod, It.IsAny())) - .Returns(Task.FromResult(executionResult)).Verifiable(); + .Returns(executionResult).Verifiable(); var mockType = new Mock().Object; mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)).Returns(mockType); mockAssemblyLoader.Setup(x => x.GetLibType(LibType.ScreenshotFilesCollector)).Returns(mockType); @@ -233,7 +232,7 @@ public async Task ShouldTakeScreenShotOnFailedExecution() var orchestrator = new ExecutionOrchestrator(mockReflectionWrapper.Object, mockAssemblyLoader.Object, mockInstance, mockHookExecuter.Object, mockStepExecutor.Object); - var result = await orchestrator.ExecuteStep(gaugeMethod, "Bar", "String"); + var result = orchestrator.ExecuteStep(gaugeMethod, "Bar", "String"); mockStepExecutor.VerifyAll(); diff --git a/test/Extensions/MethodInfoExtensionTests.cs b/test/Extensions/MethodInfoExtensionTests.cs index b0a7395..0a3f9cc 100644 --- a/test/Extensions/MethodInfoExtensionTests.cs +++ b/test/Extensions/MethodInfoExtensionTests.cs @@ -99,29 +99,5 @@ public void ShouldNotBeRecoverableWhenContinueOnFailureOnNonStep() ClassicAssert.False(bazMethod.IsRecoverableStep(assemblyLoader.Object), "Recoverable is true only when method is a Step"); } - - [Test] - public void ShouldDetectAsyncVoidReturnType() - { - var assemblyLoader = new Mock(); - var fooMethod = new MockMethodBuilder(assemblyLoader) - .WithName("Foo") - .WithAsyncVoidReturn() - .Build(); - - Assert.That(fooMethod.IsAsyncVoid(), Is.True, "Async void method was not detected."); - } - - [Test] - public void ShouldNotDetectAsyncVoidReturnTypeWhenNotPresent() - { - var assemblyLoader = new Mock(); - var fooMethod = new MockMethodBuilder(assemblyLoader) - .WithName("Foo") - .Build(); - - Assert.That(fooMethod.IsAsyncVoid(), Is.False, "Async void method was detected incorrectly."); - } - } } \ No newline at end of file diff --git a/test/Helpers/MockMethodBuilder.cs b/test/Helpers/MockMethodBuilder.cs index bcfc3ce..97ce016 100644 --- a/test/Helpers/MockMethodBuilder.cs +++ b/test/Helpers/MockMethodBuilder.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using Moq; namespace Gauge.Dotnet.UnitTests.Helpers @@ -116,13 +115,6 @@ public MockMethodBuilder WithTagAggregation(int aggregation) return this; } - public MockMethodBuilder WithAsyncVoidReturn() - { - mockMethod.Setup(x => x.ReturnType).Returns(typeof(void)); - mockMethod.Setup(x => x.GetCustomAttributes(typeof(AsyncStateMachineAttribute),true)).Returns(new []{new AsyncStateMachineAttribute(null)}); - return this; - } - private static ParameterInfo[] GetParameters(IEnumerable> methodParams) { if (methodParams is null) diff --git a/test/HookExecutorTests.cs b/test/HookExecutorTests.cs index 2518fc0..9732c92 100644 --- a/test/HookExecutorTests.cs +++ b/test/HookExecutorTests.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Reflection; using System.Threading; -using System.Threading.Tasks; using Gauge.Dotnet.Strategy; using Gauge.Dotnet.UnitTests.Helpers; using Gauge.Dotnet.Wrappers; @@ -25,7 +24,7 @@ namespace Gauge.Dotnet.UnitTests internal class HookExecutorTests { [Test] - public async Task ShoudExecuteHooks() + public void ShoudExecuteHooks() { var mockInstance = new Mock().Object; var mockClassInstanceManagerType = new Mock().Object; @@ -55,13 +54,13 @@ public async Task ShoudExecuteHooks() var executor = new HookExecutor(mockAssemblyLoader.Object, mockReflectionWrapper.Object, mockClassInstanceManager, mockExecutionInfoMapper.Object); - var result = await executor.Execute("BeforeSuite", new HooksStrategy(), new List(), + var result = executor.Execute("BeforeSuite", new HooksStrategy(), new List(), new ExecutionInfo()); ClassicAssert.True(result.Success, $"Hook execution failed: {result.ExceptionMessage}\n{result.StackTrace}"); } [Test] - public async Task ShoudExecuteHooksWithExecutionContext() + public void ShoudExecuteHooksWithExecutionContext() { var mockInstance = new Mock().Object; var mockClassInstanceManagerType = new Mock().Object; @@ -96,14 +95,14 @@ public async Task ShoudExecuteHooksWithExecutionContext() var executor = new HookExecutor(mockAssemblyLoader.Object, mockReflectionWrapper.Object, mockClassInstanceManager, mockExecutionInfoMapper.Object); - var result = await executor.Execute("BeforeSuite", new HooksStrategy(), new List(), + var result = executor.Execute("BeforeSuite", new HooksStrategy(), new List(), executionInfo); ClassicAssert.True(result.Success, $"Hook execution failed: {result.ExceptionMessage}\n{result.StackTrace}"); mockReflectionWrapper.VerifyAll(); } [Test] - public async Task ShoudExecuteHooksAndGetTheError() + public void ShoudExecuteHooksAndGetTheError() { var mockInstance = new Mock().Object; var mockClassInstanceManagerType = new Mock().Object; @@ -130,10 +129,10 @@ public async Task ShoudExecuteHooksAndGetTheError() .Returns(new { Foo = "bar" }); var executor = new HookExecutor(mockAssemblyLoader.Object, mockReflectionWrapper.Object, mockClassInstanceManager, mockExecutionInfoMapper.Object); - mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance, It.IsAny())) + mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance)) .Throws(new Exception("hook failed")); - var result = await executor.Execute("BeforeSuite", new HooksStrategy(), new List(), + var result = executor.Execute("BeforeSuite", new HooksStrategy(), new List(), new ExecutionInfo()); ClassicAssert.False(result.Success, "Hook execution passed, expected failure"); ClassicAssert.AreEqual(result.ExceptionMessage, "hook failed"); diff --git a/test/Processors/ExecuteStepProcessorTests.cs b/test/Processors/ExecuteStepProcessorTests.cs index 1413738..c09641f 100644 --- a/test/Processors/ExecuteStepProcessorTests.cs +++ b/test/Processors/ExecuteStepProcessorTests.cs @@ -5,7 +5,6 @@ *----------------------------------------------------------------*/ -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Messages; @@ -23,7 +22,7 @@ public void Foo(string param) } [Test] - public async Task ShouldProcessExecuteStepRequest() + public void ShouldProcessExecuteStepRequest() { const string parsedStepText = "Foo"; var request = new ExecuteStepRequest @@ -46,12 +45,12 @@ public async Task ShouldProcessExecuteStepRequest() mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockOrchestrator = new Mock(); mockOrchestrator.Setup(e => e.ExecuteStep(fooMethodInfo, It.IsAny())) - .Returns(() => Task.FromResult(new ProtoExecutionResult { ExecutionTime = 1, Failed = false })); + .Returns(() => new ProtoExecutionResult { ExecutionTime = 1, Failed = false }); var mockTableFormatter = new Mock(); var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); - var response = await processor.Process(request); + var response = processor.Process(request); ClassicAssert.False(response.ExecutionResult.Failed); } @@ -59,7 +58,7 @@ public async Task ShouldProcessExecuteStepRequest() [Test] [TestCase(Parameter.Types.ParameterType.Table)] [TestCase(Parameter.Types.ParameterType.SpecialTable)] - public async Task ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.ParameterType parameterType) + public void ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.ParameterType parameterType) { const string parsedStepText = "Foo"; var protoTable = new ProtoTable(); @@ -84,11 +83,11 @@ public async Task ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.P mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo); var mockOrchestrator = new Mock(); mockOrchestrator.Setup(e => e.ExecuteStep(fooMethodInfo, It.IsAny())).Returns(() => - Task.FromResult(new ProtoExecutionResult + new ProtoExecutionResult { ExecutionTime = 1, Failed = false - })); + }); var mockAssemblyLoader = new Mock(); mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)); @@ -96,7 +95,7 @@ public async Task ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.P mockTableFormatter.Setup(x => x.GetJSON(protoTable)) .Returns(tableJSON); var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); - var response = await processor.Process(request); + var response = processor.Process(request); mockOrchestrator.Verify(executor => executor.ExecuteStep(fooMethodInfo, It.Is(strings => strings[0] == tableJSON))); @@ -104,7 +103,7 @@ public async Task ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.P } [Test] - public async Task ShouldReportArgumentMismatch() + public void ShouldReportArgumentMismatch() { const string parsedStepText = "Foo"; var request = new ExecuteStepRequest @@ -121,7 +120,7 @@ public async Task ShouldReportArgumentMismatch() var mockTableFormatter = new Mock(); var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); - var response = await processor.Process(request); + var response = processor.Process(request); ClassicAssert.True(response.ExecutionResult.Failed); ClassicAssert.AreEqual(response.ExecutionResult.ErrorMessage, @@ -129,7 +128,7 @@ public async Task ShouldReportArgumentMismatch() } [Test] - public async Task ShouldReportMissingStep() + public void ShouldReportMissingStep() { const string parsedStepText = "Foo"; var request = new ExecuteStepRequest @@ -143,7 +142,7 @@ public async Task ShouldReportMissingStep() var mockTableFormatter = new Mock(); var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); - var response = await processor.Process(request); + var response = processor.Process(request); ClassicAssert.True(response.ExecutionResult.Failed); ClassicAssert.AreEqual(response.ExecutionResult.ErrorMessage, diff --git a/test/Processors/ExecutionEndingProcessorTests.cs b/test/Processors/ExecutionEndingProcessorTests.cs index 162ff61..f07f1d1 100644 --- a/test/Processors/ExecutionEndingProcessorTests.cs +++ b/test/Processors/ExecutionEndingProcessorTests.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -54,7 +53,7 @@ public void Setup() _mockMethodExecutor.Setup(x => x.ExecuteHooks("AfterSuite", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(_protoExecutionResult)); + .Returns(_protoExecutionResult); _mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(_pendingMessages); _mockMethodExecutor.Setup(x => @@ -87,9 +86,9 @@ public void ShouldGetEmptyTagListByDefault() } [Test] - public async Task ShouldProcessHooks() + public void ShouldProcessHooks() { - var result = await _executionEndingProcessor.Process(_request); + var result = _executionEndingProcessor.Process(_request); _mockMethodExecutor.VerifyAll(); ClassicAssert.AreEqual(result.ExecutionResult.Message, _pendingMessages); ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles, _pendingScreenshotFiles); diff --git a/test/Processors/ExecutionStartingProcessorTests.cs b/test/Processors/ExecutionStartingProcessorTests.cs index c1067a0..6a454bc 100644 --- a/test/Processors/ExecutionStartingProcessorTests.cs +++ b/test/Processors/ExecutionStartingProcessorTests.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -47,7 +46,7 @@ public void Setup() _mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeSuite", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(_protoExecutionResult)); + .Returns(_protoExecutionResult); _mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(_pendingMessages); _mockMethodExecutor.Setup(x => @@ -101,10 +100,10 @@ public void ShouldGetEmptyTagListByDefault() } [Test] - public async Task ShouldProcessHooks() + public void ShouldProcessHooks() { var executionStartingRequest = new ExecutionStartingRequest(); - var result = await _executionStartingProcessor.Process(executionStartingRequest); + var result = _executionStartingProcessor.Process(executionStartingRequest); _mockMethodExecutor.VerifyAll(); ClassicAssert.AreEqual(result.ExecutionResult.Message, _pendingMessages); diff --git a/test/Processors/ScenarioExecutionEndingProcessorTests.cs b/test/Processors/ScenarioExecutionEndingProcessorTests.cs index f20f7ad..0cdb3ab 100644 --- a/test/Processors/ScenarioExecutionEndingProcessorTests.cs +++ b/test/Processors/ScenarioExecutionEndingProcessorTests.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; @@ -46,6 +45,10 @@ public void ShouldGetTagListFromSpecAndScenario() CurrentSpec = specInfo, CurrentScenario = scenarioInfo }; + var currentExecutionInfo = new ScenarioExecutionEndingRequest + { + CurrentExecutionInfo = currentScenario + }; var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); @@ -87,7 +90,7 @@ public void ShouldNotGetDuplicateTags() } [Test] - public async Task ShouldExecutreBeforeScenarioHook() + public void ShouldExecutreBeforeScenarioHook() { var scenarioExecutionStartingRequest = new ScenarioExecutionEndingRequest { @@ -110,7 +113,7 @@ public async Task ShouldExecutreBeforeScenarioHook() mockMethodExecutor.Setup(x => x.ExecuteHooks("AfterScenario", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(protoExecutionResult)); + .Returns(protoExecutionResult); mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(pendingMessages); mockMethodExecutor.Setup(x => @@ -118,7 +121,7 @@ public async Task ShouldExecutreBeforeScenarioHook() var processor = new ScenarioExecutionEndingProcessor(mockMethodExecutor.Object); - var result = await processor.Process(scenarioExecutionStartingRequest); + var result = processor.Process(scenarioExecutionStartingRequest); ClassicAssert.False(result.ExecutionResult.Failed); ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); diff --git a/test/Processors/ScenarioExecutionStartingProcessorTests.cs b/test/Processors/ScenarioExecutionStartingProcessorTests.cs index c187be9..7ea08be 100644 --- a/test/Processors/ScenarioExecutionStartingProcessorTests.cs +++ b/test/Processors/ScenarioExecutionStartingProcessorTests.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; @@ -46,7 +45,12 @@ public void ShouldGetTagListFromExecutionInfo() CurrentSpec = specInfo, CurrentScenario = scenarioInfo }; - + var currentExecutionInfo = new ScenarioExecutionStartingRequest + { + CurrentExecutionInfo = currentScenario + }; + + var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); @@ -88,7 +92,7 @@ public void ShouldNotFetchDuplicateTags() } [Test] - public async Task ShouldExecuteBeforeScenarioHook() + public void ShouldExecuteBeforeScenarioHook() { var scenarioExecutionEndingRequest = new ScenarioExecutionStartingRequest { @@ -112,7 +116,7 @@ public async Task ShouldExecuteBeforeScenarioHook() mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeScenario", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(protoExecutionResult)); + .Returns(protoExecutionResult); mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(pendingMessages); mockMethodExecutor.Setup(x => @@ -120,7 +124,7 @@ public async Task ShouldExecuteBeforeScenarioHook() var processor = new ScenarioExecutionStartingProcessor(mockMethodExecutor.Object); - var result = await processor.Process(scenarioExecutionEndingRequest); + var result = processor.Process(scenarioExecutionEndingRequest); ClassicAssert.False(result.ExecutionResult.Failed); ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); diff --git a/test/Processors/SpecExecutionEndingProcessorTests.cs b/test/Processors/SpecExecutionEndingProcessorTests.cs index 1b1e796..2b4d9e9 100644 --- a/test/Processors/SpecExecutionEndingProcessorTests.cs +++ b/test/Processors/SpecExecutionEndingProcessorTests.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; @@ -49,7 +48,7 @@ public void ShouldGetTagListFromExecutionInfo() } [Test] - public async Task ShouldExecuteBeforeSpecHook() + public void ShouldExecuteBeforeSpecHook() { var request = new SpecExecutionEndingRequest { @@ -72,14 +71,14 @@ public async Task ShouldExecuteBeforeSpecHook() mockMethodExecutor.Setup(x => x.ExecuteHooks("AfterSpec", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(protoExecutionResult)); + .Returns(protoExecutionResult); mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(pendingMessages); mockMethodExecutor.Setup(x => x.GetAllPendingScreenshotFiles()).Returns(pendingScreenshotFiles); var processor = new SpecExecutionEndingProcessor(mockMethodExecutor.Object); - var result = await processor.Process(request); + var result = processor.Process(request); ClassicAssert.False(result.ExecutionResult.Failed); ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); diff --git a/test/Processors/SpecExecutionStartingProcessorTests.cs b/test/Processors/SpecExecutionStartingProcessorTests.cs index a576561..33f4c2b 100644 --- a/test/Processors/SpecExecutionStartingProcessorTests.cs +++ b/test/Processors/SpecExecutionStartingProcessorTests.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; @@ -49,7 +48,7 @@ public void ShouldGetTagListFromExecutionInfo() } [Test] - public async Task ShouldExecutreBeforeSpecHook() + public void ShouldExecutreBeforeSpecHook() { var specExecutionStartingRequest = new SpecExecutionStartingRequest { @@ -73,7 +72,7 @@ public async Task ShouldExecutreBeforeSpecHook() mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeSpec", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(protoExecutionResult)); + .Returns(protoExecutionResult); mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(pendingMessages); mockMethodExecutor.Setup(x => @@ -81,7 +80,7 @@ public async Task ShouldExecutreBeforeSpecHook() var processor = new SpecExecutionStartingProcessor(mockMethodExecutor.Object); - var result = await processor.Process(request); + var result = processor.Process(request); ClassicAssert.False(result.ExecutionResult.Failed); ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); diff --git a/test/Processors/StepExecutionEndingProcessorTests.cs b/test/Processors/StepExecutionEndingProcessorTests.cs index 4399c1c..15c33cc 100644 --- a/test/Processors/StepExecutionEndingProcessorTests.cs +++ b/test/Processors/StepExecutionEndingProcessorTests.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -71,7 +70,7 @@ public void Setup() _mockMethodExecutor.Setup(x => x.ExecuteHooks("AfterStep", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(_protoExecutionResult)); + .Returns(_protoExecutionResult); _mockMethodExecutor.Setup(x => x.GetAllPendingMessages()).Returns(_pendingMessages); _mockMethodExecutor.Setup(x => @@ -86,9 +85,9 @@ public void ShouldExtendFromHooksExecutionProcessor() } [Test] - public async Task ShouldReadPendingMessages() + public void ShouldReadPendingMessages() { - var response = await _stepExecutionEndingProcessor.Process(_stepExecutionEndingRequest); + var response = _stepExecutionEndingProcessor.Process(_stepExecutionEndingRequest); ClassicAssert.True(response != null); ClassicAssert.True(response.ExecutionResult != null); diff --git a/test/Processors/StepExecutionStartingProcessorTests.cs b/test/Processors/StepExecutionStartingProcessorTests.cs index 1cc086d..3c9919d 100644 --- a/test/Processors/StepExecutionStartingProcessorTests.cs +++ b/test/Processors/StepExecutionStartingProcessorTests.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -27,7 +26,7 @@ public void ShouldExtendFromHooksExecutionProcessor() } [Test] - public async Task ShouldClearExistingGaugeMessages() + public void ShouldClearExistingGaugeMessages() { var mockExecutionHelper = new Mock(); @@ -44,7 +43,7 @@ public async Task ShouldClearExistingGaugeMessages() mockExecutionHelper.Setup(executor => executor.ExecuteHooks(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(protoExecutionResult)); + .Returns(protoExecutionResult); var hookRegistry = new Mock(); hookRegistry.Setup(registry => registry.BeforeStepHooks).Returns(new HashSet()); @@ -54,14 +53,14 @@ public async Task ShouldClearExistingGaugeMessages() mockExecutionHelper.Setup(x => x.ExecuteHooks("BeforeStep", It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns(Task.FromResult(protoExecutionResult)); + .Returns(protoExecutionResult); mockExecutionHelper.Setup(x => x.GetAllPendingMessages()).Returns(pendingMessages); mockExecutionHelper.Setup(x => x.GetAllPendingScreenshotFiles()).Returns(pendingScreenshotFiles); var processor = new StepExecutionStartingProcessor(mockExecutionHelper.Object); - var result = await processor.Process(request); + var result = processor.Process(request); ClassicAssert.AreEqual(result.ExecutionResult.Message, pendingMessages); ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles, pendingScreenshotFiles); } diff --git a/test/StepExecutorTests.cs b/test/StepExecutorTests.cs index 722fee0..d3492d9 100644 --- a/test/StepExecutorTests.cs +++ b/test/StepExecutorTests.cs @@ -7,7 +7,6 @@ using System; using System.Threading; -using System.Threading.Tasks; using Gauge.Dotnet.Models; using Gauge.Dotnet.UnitTests.Helpers; using Gauge.Dotnet.Wrappers; @@ -21,7 +20,7 @@ namespace Gauge.Dotnet.UnitTests internal class StepExecutorTests { [Test] - public async Task ShoudExecuteStep() + public void ShoudExecuteStep() { var mockInstance = new Mock().Object; var mockClassInstanceManagerType = new Mock().Object; @@ -51,12 +50,13 @@ public async Task ShoudExecuteStep() mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance)) .Returns(null); - var result = await executor.Execute(gaugeMethod); + + var result = executor.Execute(gaugeMethod); ClassicAssert.True(result.Success); } [Test] - public async Task ShoudExecuteStepAndGetFailure() + public void ShoudExecuteStepAndGetFailure() { var mockInstance = new Mock().Object; var mockClassInstanceManagerType = new Mock().Object; @@ -86,13 +86,13 @@ public async Task ShoudExecuteStepAndGetFailure() mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance)) .Throws(new Exception("step execution failure")); - var result = await executor.Execute(gaugeMethod); + var result = executor.Execute(gaugeMethod); ClassicAssert.False(result.Success); ClassicAssert.AreEqual(result.ExceptionMessage, "step execution failure"); } [Test] - public async Task ShoudExecuteStepAndGetRecoverableError() + public void ShoudExecuteStepAndGetRecoverableError() { var mockInstance = new Mock().Object; var mockClassInstanceManagerType = new Mock().Object; @@ -124,7 +124,7 @@ public async Task ShoudExecuteStepAndGetRecoverableError() mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance)) .Throws(new Exception("step execution failure")); - var result = await executor.Execute(gaugeMethod); + var result = executor.Execute(gaugeMethod); ClassicAssert.False(result.Success); ClassicAssert.True(result.Recoverable); ClassicAssert.AreEqual(result.ExceptionMessage, "step execution failure"); diff --git a/test/StepRegistryTests.cs b/test/StepRegistryTests.cs index af7854d..ce5e1b5 100644 --- a/test/StepRegistryTests.cs +++ b/test/StepRegistryTests.cs @@ -8,8 +8,6 @@ using System.Collections.Generic; using System.Linq; using Gauge.Dotnet.Models; -using Gauge.Dotnet.UnitTests.Helpers; -using Moq; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -189,23 +187,10 @@ public void ShouldNotContainStepPositionForExternalSteps() stepRegistry.AddStep("Foo", new GaugeMethod { Name = "Foo", StepText = "Foo", FileName = "foo.cs" }); stepRegistry.AddStep("Bar", new GaugeMethod { Name = "Bar", StepText = "Bar", IsExternal = true }); - var positions = stepRegistry.GetStepPositions("foo.cs").ToArray(); + var positions = stepRegistry.GetStepPositions("foo.cs"); - Assert.That(positions.Length, Is.EqualTo(1)); - Assert.That(positions.First().StepValue, Is.Not.EqualTo("Bar")); - } - - [Test] - public void ShouldCheckForAsyncVoidImplementation() - { - var stepRegistry = new StepRegistry(); - var mockAssemblyLoader = new Mock(); - var mockMethodBuilder = new MockMethodBuilder(mockAssemblyLoader); - var impl = new GaugeMethod { MethodInfo = mockMethodBuilder.WithName("Foo").WithStep("Foo").WithAsyncVoidReturn().Build() }; - - stepRegistry.AddStep("Foo", impl); - - Assert.That(stepRegistry.HasAsyncVoidImplementation("Foo"), Is.True); + ClassicAssert.True(positions.Count() == 1); + ClassicAssert.AreNotEqual(positions.First().StepValue, "Bar"); } } } \ No newline at end of file diff --git a/test/ValidateProcessorTests.cs b/test/ValidateProcessorTests.cs index 0709c29..7967559 100644 --- a/test/ValidateProcessorTests.cs +++ b/test/ValidateProcessorTests.cs @@ -48,7 +48,7 @@ public void ShouldGetErrorResponseForStepValidateRequestWhenMultipleStepImplFoun } [Test] - public void ShouldGetErrorResponseForStepValidateRequestWhenNoImplFound() + public void ShouldGetErrorResponseForStepValidateRequestWhennNoImplFound() { var request = new StepValidateRequest { @@ -73,7 +73,7 @@ public void ShouldGetErrorResponseForStepValidateRequestWhenNoImplFound() [Test] - public void ShouldGetValidResponseForStepValidateRequest() + public void ShouldGetVaildResponseForStepValidateRequest() { var request = new StepValidateRequest { @@ -83,38 +83,11 @@ public void ShouldGetValidResponseForStepValidateRequest() _mockStepRegistry.Setup(registry => registry.ContainsStep("step_text_1")).Returns(true); _mockStepRegistry.Setup(registry => registry.HasMultipleImplementations("step_text_1")).Returns(false); - _mockStepRegistry.Setup(registry => registry.HasAsyncVoidImplementation("step_text_1")).Returns(false); - - var response = new StepValidationProcessor(_mockStepRegistry.Object).Process(request); - - Assert.That(response.IsValid, Is.True, $"Expected true, got error: {response.ErrorMessage}"); - } - [Test] - public void ShouldGetErrorResponseForStepValidateRequestWhenAsyncVoidImplFound() - { - var request = new StepValidateRequest - { - StepText = "step_text_1", - NumberOfParameters = 0, - StepValue = new ProtoStepValue - { - ParameterizedStepValue = "step_text_1", - StepValue = "step_text_1" - } - }; - _mockStepRegistry.Setup(registry => registry.ContainsStep("step_text_1")).Returns(true); - _mockStepRegistry.Setup(registry => registry.HasMultipleImplementations("step_text_1")).Returns(false); - _mockStepRegistry.Setup(registry => registry.HasAsyncVoidImplementation("step_text_1")).Returns(true); var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); - ClassicAssert.AreEqual(false, response.IsValid); - ClassicAssert.AreEqual(StepValidateResponse.Types.ErrorType.StepImplementationNotFound, - response.ErrorType); - StringAssert.StartsWith("Found a potential step implementation with 'async void' return for : step_text_1.", - response.Suggestion); - StringAssert.Contains("Usage of 'async void' is discouraged", response.Suggestion); + ClassicAssert.AreEqual(true, response.IsValid); } } } \ No newline at end of file