Skip to content

Commit

Permalink
Add .NET 8 support (#200)
Browse files Browse the repository at this point in the history
* Add .NET 8 support

Signed-off-by: Martin Pekurny <[email protected]>

* Update the init command to create a newer csproj file and removed the matrix for different dotnet versions in the build.yml

Signed-off-by: Martin Pekurny <[email protected]>

* Limiting the number of nodes to use for the feature tests

Signed-off-by: Martin Pekurny <[email protected]>

---------

Signed-off-by: Martin Pekurny <[email protected]>
Signed-off-by: sriv <[email protected]>
  • Loading branch information
mpekurny authored and sriv committed Feb 6, 2024
1 parent b115eb0 commit 2373591
Show file tree
Hide file tree
Showing 51 changed files with 446 additions and 416 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Dotnet unit test on windows
if: matrix.os == 'windows-latest'
Expand All @@ -45,7 +45,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
dotnet: [7.0.x, 6.0.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -62,7 +61,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- uses: getgauge/setup-gauge@master
with:
Expand All @@ -86,14 +85,14 @@ jobs:
if: matrix.os != 'windows-latest'
run: |
cd gauge-tests
./gradlew clean dotnetFT
./gradlew -Pnodes=2 clean dotnetFT
- name: Run FTs on windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
cd gauge-tests
.\gradlew.bat clean dotnetFT
.\gradlew.bat -Pnodes=2 clean dotnetFT
- uses: actions/upload-artifact@v3
if: failure()
Expand All @@ -118,7 +117,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- uses: getgauge/setup-gauge@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Setup git
run: |
Expand Down
13 changes: 7 additions & 6 deletions integration-test/ExecuteStepProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
*----------------------------------------------------------------*/


using System.Threading;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Processors;
using Gauge.Dotnet.Wrappers;
using Gauge.Messages;
using NUnit.Framework;
using System.Threading;
using NUnit.Framework.Legacy;

namespace Gauge.Dotnet.IntegrationTests
{
Expand Down Expand Up @@ -66,8 +67,8 @@ public void ShouldExecuteMethodFromRequest()
var result = executeStepProcessor.Process(message);

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

[Test]
Expand Down Expand Up @@ -98,9 +99,9 @@ public void ShouldCaptureScreenshotOnFailure()
var result = executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;

Assert.IsNotNull(protoExecutionResult);
Assert.IsTrue(protoExecutionResult.Failed);
Assert.AreEqual("screenshot.png", protoExecutionResult.FailureScreenshotFile);
ClassicAssert.IsNotNull(protoExecutionResult);
ClassicAssert.IsTrue(protoExecutionResult.Failed);
ClassicAssert.AreEqual("screenshot.png", protoExecutionResult.FailureScreenshotFile);
}
}
}
35 changes: 18 additions & 17 deletions integration-test/ExecutionOrchestratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Wrappers;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace Gauge.Dotnet.IntegrationTests
{
Expand All @@ -33,8 +34,8 @@ public void RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
var gaugeMethod = assemblyLoader.GetStepRegistry()
.MethodFor("I throw a serializable exception and continue");
var executionResult = orchestrator.ExecuteStep(gaugeMethod);
Assert.IsTrue(executionResult.Failed);
Assert.IsTrue(executionResult.RecoverableError);
ClassicAssert.IsTrue(executionResult.Failed);
ClassicAssert.IsTrue(executionResult.RecoverableError);
}

[Test]
Expand All @@ -56,7 +57,7 @@ public void ShouldCreateTableFromTargetType()
table.AddRow(new List<string> { "foorow2", "barrow2" });

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

[Test]
Expand All @@ -76,7 +77,7 @@ public void ShouldExecuteMethodAndReturnResult()
.MethodFor("A context step which gets executed before every scenario");

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

[Test]
Expand All @@ -97,8 +98,8 @@ public void ShouldGetPendingMessages()

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

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

[Test]
Expand All @@ -119,8 +120,8 @@ public void ShouldExecuteAsyncStepImplementation()

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

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

[Test]
Expand All @@ -140,9 +141,9 @@ public void ShouldGetStacktraceForAggregateException()
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an AggregateException");
var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);

Assert.True(executionResult.Failed);
Assert.True(executionResult.StackTrace.Contains("First Exception"));
Assert.True(executionResult.StackTrace.Contains("Second Exception"));
ClassicAssert.True(executionResult.Failed);
ClassicAssert.True(executionResult.StackTrace.Contains("First Exception"));
ClassicAssert.True(executionResult.StackTrace.Contains("Second Exception"));
}

[Test]
Expand All @@ -156,8 +157,8 @@ public void ShouldGetStepTextsForMethod()
var gaugeMethod = registry.MethodFor("and an alias");
var stepTexts = gaugeMethod.Aliases.ToList();

Assert.Contains("Step with text", stepTexts);
Assert.Contains("and an alias", stepTexts);
ClassicAssert.Contains("Step with text", stepTexts);
ClassicAssert.Contains("and an alias", stepTexts);
}

[Test]
Expand All @@ -178,8 +179,8 @@ public void SuccessIsFalseOnSerializableExceptionThrown()

var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);

Assert.True(executionResult.Failed);
Assert.AreEqual(expectedMessage, executionResult.ErrorMessage);
ClassicAssert.True(executionResult.Failed);
ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage);
StringAssert.Contains("IntegrationTestSample.StepImplementation.ThrowSerializableException",
executionResult.StackTrace);
}
Expand All @@ -201,8 +202,8 @@ public void SuccessIsFalseOnUnserializableExceptionThrown()

var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an unserializable exception");
var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);
Assert.True(executionResult.Failed);
Assert.AreEqual(expectedMessage, executionResult.ErrorMessage);
ClassicAssert.True(executionResult.Failed);
ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage);
StringAssert.Contains("IntegrationTestSample.StepImplementation.ThrowUnserializableException",
executionResult.StackTrace);
}
Expand Down
7 changes: 4 additions & 3 deletions integration-test/ExternalReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Gauge.Dotnet.Wrappers;
using Gauge.Messages;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace Gauge.Dotnet.IntegrationTests
{
Expand All @@ -35,7 +36,7 @@ public void ShouldGetStepsFromReference(string referenceType, string stepText, s
};
var result = stepValidationProcessor.Process(message);

Assert.IsTrue(result.IsValid, $"Expected valid step text, got error: {result.ErrorMessage}");
ClassicAssert.IsTrue(result.IsValid, $"Expected valid step text, got error: {result.ErrorMessage}");
}


Expand Down Expand Up @@ -68,9 +69,9 @@ public void ShouldRegisterScreenshotWriterFromReference(string referenceType, st
var result = executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;

Assert.IsNotNull(protoExecutionResult);
ClassicAssert.IsNotNull(protoExecutionResult);
Console.WriteLine(protoExecutionResult.ScreenshotFiles[0]);
Assert.AreEqual(protoExecutionResult.ScreenshotFiles[0], expected);
ClassicAssert.AreEqual(protoExecutionResult.ScreenshotFiles[0], expected);
}

[TearDown]
Expand Down
8 changes: 4 additions & 4 deletions integration-test/Gauge.Dotnet.IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
45 changes: 23 additions & 22 deletions integration-test/ImplementCodeProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Gauge.Dotnet.Processors;
using Gauge.Messages;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace Gauge.Dotnet.IntegrationTests
{
Expand All @@ -29,12 +30,12 @@ public void ShouldProcessMessage()

var processor = new StubImplementationCodeProcessor();
var result = processor.Process(message);
Assert.AreEqual("StepImplementation1.cs", Path.GetFileName(result.FilePath));
Assert.AreEqual(1, result.TextDiffs.Count);
ClassicAssert.AreEqual("StepImplementation1.cs", Path.GetFileName(result.FilePath));
ClassicAssert.AreEqual(1, result.TextDiffs.Count);
Console.WriteLine(result.TextDiffs[0].Content);
Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
Assert.True(result.TextDiffs[0].Content.Contains("class StepImplementation1"));
Assert.AreEqual(result.TextDiffs[0].Span.Start, 0);
ClassicAssert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
ClassicAssert.True(result.TextDiffs[0].Content.Contains("class StepImplementation1"));
ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 0);
}

[Test]
Expand All @@ -52,11 +53,11 @@ public void ShouldProcessMessageForExistingButEmptyFile()

var processor = new StubImplementationCodeProcessor();
var result = processor.Process(message);
Assert.AreEqual(1, result.TextDiffs.Count);
Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
Assert.True(result.TextDiffs[0].Content.Contains("class Empty"));
ClassicAssert.AreEqual(1, result.TextDiffs.Count);
ClassicAssert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
ClassicAssert.True(result.TextDiffs[0].Content.Contains("class Empty"));
StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
Assert.AreEqual(result.TextDiffs[0].Span.Start, 0);
ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 0);
}

[Test]
Expand All @@ -74,9 +75,9 @@ public void ShouldProcessMessageForExistingClass()

var processor = new StubImplementationCodeProcessor();
var result = processor.Process(message);
Assert.AreEqual(1, result.TextDiffs.Count);
ClassicAssert.AreEqual(1, result.TextDiffs.Count);
StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
Assert.AreEqual(115, result.TextDiffs[0].Span.Start);
ClassicAssert.AreEqual(115, result.TextDiffs[0].Span.Start);
}

[Test]
Expand All @@ -94,32 +95,32 @@ public void ShouldProcessMessageForExistingFileWithEmptyClass()

var processor = new StubImplementationCodeProcessor();
var result = processor.Process(message);
Assert.AreEqual(1, result.TextDiffs.Count);
ClassicAssert.AreEqual(1, result.TextDiffs.Count);
StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
Assert.True(result.TextDiffs[0].Content.Contains("Step Method"));
Assert.AreEqual(result.TextDiffs[0].Span.Start, 8);
ClassicAssert.True(result.TextDiffs[0].Content.Contains("Step Method"));
ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 8);
}

[Test]
public void ShouldProcessMessageForExistingFileWithSomeComments()
{
var file = Path.Combine(_testProjectPath, "CommentFile.cs");
var message = new StubImplementationCodeRequest
{
ImplementationFilePath = file,
Codes =
{
ImplementationFilePath = file,
Codes =
{
"Step Method"
}
};
};

var processor = new StubImplementationCodeProcessor();
var result = processor.Process(message);
Assert.AreEqual(1, result.TextDiffs.Count);
ClassicAssert.AreEqual(1, result.TextDiffs.Count);
StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
Assert.True(result.TextDiffs[0].Content.Contains("class CommentFile"));
Assert.AreEqual(result.TextDiffs[0].Span.Start, 3);
ClassicAssert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
ClassicAssert.True(result.TextDiffs[0].Content.Contains("class CommentFile"));
ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 3);
}
}
}
Loading

0 comments on commit 2373591

Please sign in to comment.