Skip to content

Commit

Permalink
Feat/dojo improvement (#207)
Browse files Browse the repository at this point in the history
* dojo improvement

* add external tests

* target real devices

* fix asserts

* prepare next tunit release

* prepare next release
  • Loading branch information
agray authored Dec 21, 2024
1 parent d2217ae commit d3f9a6f
Show file tree
Hide file tree
Showing 26 changed files with 547 additions and 402 deletions.
26 changes: 11 additions & 15 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ jobs:

tunit-real-integration-tests:
runs-on: ubuntu-latest
needs: tunit-integration-tests
needs: [nunit-integration-tests,
xunit-integration-tests,
xunit-external-tests,
nunit-external-tests,
xunit-real-external-tests,
nunit-real-external-tests]

steps:
- name: Checkout Code
Expand Down Expand Up @@ -372,7 +377,8 @@ jobs:

tunit-external-tests:
runs-on: ubuntu-latest
needs: tunit-real-integration-tests
needs: [tunit-real-integration-tests,
tunit-integration-tests]

steps:
- name: Checkout Code
Expand All @@ -392,7 +398,8 @@ jobs:

tunit-real-external-tests:
runs-on: ubuntu-latest
needs: tunit-external-tests
needs: [tunit-real-integration-tests,
tunit-integration-tests]

steps:
- name: Checkout Code
Expand All @@ -412,18 +419,7 @@ jobs:

generate-report:
runs-on: ubuntu-latest
needs: [build,
nunit-integration-tests,
xunit-integration-tests,
nunit-real-integration-tests,
xunit-real-integration-tests,
nunit-external-tests,
xunit-external-tests,
nunit-real-external-tests,
xunit-real-external-tests,
tunit-integration-tests,
tunit-real-integration-tests,
tunit-external-tests,
needs: [tunit-external-tests,
tunit-real-external-tests]

steps:
Expand Down
31 changes: 31 additions & 0 deletions ExternalMerlin.TUnit.RealDevices/ClickLinkTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using ExternalMerlin.TUnit.RealDevices;
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.TUnit;
using Shouldly;

[assembly: ParallelLimiter<MyParallelLimit>]

namespace ExternalMerlin.TUnit.RealDevices;

public class ClickLinkTests : SauceryTBase
{
[Test]
[MethodDataSource(typeof(RequestedPlatformData), nameof(RequestedPlatformData.AllPlatforms))]
public async Task ClickLinkTest(BrowserVersion requestedPlatform)
{
InitialiseDriver(requestedPlatform);

var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");

guineaPigPage.ClickLink(SauceryDriver());

// verify the browser was navigated to the correct page
await Assert.That(Driver!.Url).Contains("saucelabs.com/test-guinea-pig2.html");
}
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
35 changes: 35 additions & 0 deletions ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.TUnit;

namespace ExternalMerlin.TUnit.RealDevices;

public class DataDrivenTests : SauceryTBase
{
[Test]
[MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])]
public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);

var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");

guineaPigPage.TypeField(SauceryDriver(), "comments", data.ToString());

var commentField = guineaPigPage.GetField(SauceryDriver(), "comments");
await Assert.That(commentField).IsNotNull();

var commentText = commentField.GetDomProperty("value");
await Assert.That(commentText).Contains(data.ToString());
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList()

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / build

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / nunit-integration-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / nunit-real-integration-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / xunit-integration-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / xunit-external-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / nunit-external-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / nunit-real-external-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / xunit-real-external-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / tunit-integration-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / tunit-external-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / build, pack & push Saucery.TUnit

Return a `Func<T>` rather than a `<T>`.
from datum in data
select (browserVersion, datum);
}

/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Saucery.TUnit" Version="0.5.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Saucery.Tests.Common\Saucery.Tests.Common.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions ExternalMerlin.TUnit.RealDevices/MyParallelLimit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using TUnit.Core.Interfaces;

namespace ExternalMerlin.TUnit.RealDevices;

public record MyParallelLimit : IParallelLimit
{
public int Limit => 3;
}
29 changes: 29 additions & 0 deletions ExternalMerlin.TUnit.RealDevices/RequestedPlatformData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Saucery.Core.DataSources;
using Saucery.Core.Dojo;
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;

namespace ExternalMerlin.TUnit.RealDevices;

public class RequestedPlatformData : SauceryTestData
{
static RequestedPlatformData()
{
var platforms = new List<SaucePlatform>
{
//Real Devices
new AndroidRealDevice("Google.*", "15"),
new IOSRealDevice("iPhone 14 Pro Max", "16"),
};

SetPlatforms(platforms);
}

public static List<Func<BrowserVersion>> AllPlatforms() => GetAllPlatformsAsFunc();
public static List<BrowserVersion> AllPlatformsAsList() => GetAllPlatformsAsList();
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 12th July 2024
*
*/
31 changes: 31 additions & 0 deletions ExternalMerlin.TUnit/ClickLinkTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using ExternalMerlin.TUnit;
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.TUnit;
using Shouldly;

[assembly: ParallelLimiter<MyParallelLimit>]

namespace ExternalMerlin.TUnit;

public class ClickLinkTests : SauceryTBase
{
[Test]
[MethodDataSource(typeof(RequestedPlatformData), nameof(RequestedPlatformData.AllPlatforms))]
public async Task ClickLinkTest(BrowserVersion requestedPlatform)
{
InitialiseDriver(requestedPlatform);

var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");

guineaPigPage.ClickLink(SauceryDriver());

// verify the browser was navigated to the correct page
await Assert.That(Driver!.Url).Contains("saucelabs.com/test-guinea-pig2.html");
}
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
35 changes: 35 additions & 0 deletions ExternalMerlin.TUnit/DataDrivenTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.TUnit;

namespace ExternalMerlin.TUnit;

public class DataDrivenTests : SauceryTBase
{
[Test]
[MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])]
public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);

var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");

guineaPigPage.TypeField(SauceryDriver(), "comments", data.ToString());

var commentField = guineaPigPage.GetField(SauceryDriver(), "comments");
await Assert.That(commentField).IsNotNull();

var commentText = commentField.GetDomProperty("value");
await Assert.That(commentText).Contains(data.ToString());
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList()

Check warning on line 26 in ExternalMerlin.TUnit/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / xunit-real-integration-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / tunit-real-integration-tests

Return a `Func<T>` rather than a `<T>`.

Check warning on line 26 in ExternalMerlin.TUnit/DataDrivenTests.cs

View workflow job for this annotation

GitHub Actions / tunit-real-external-tests

Return a `Func<T>` rather than a `<T>`.
from datum in data
select (browserVersion, datum);
}

/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
8 changes: 8 additions & 0 deletions ExternalMerlin.TUnit/ExternalMerlin.TUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Saucery.TUnit" Version="0.5.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Saucery.Tests.Common\Saucery.Tests.Common.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions ExternalMerlin.TUnit/MyParallelLimit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using TUnit.Core.Interfaces;

namespace ExternalMerlin.TUnit;

public record MyParallelLimit : IParallelLimit
{
public int Limit => 3;
}
34 changes: 34 additions & 0 deletions ExternalMerlin.TUnit/RequestedPlatformData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Saucery.Core.DataSources;
using Saucery.Core.Dojo;
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;
using Saucery.Core.Util;

namespace ExternalMerlin.TUnit;

public class RequestedPlatformData : SauceryTestData
{
static RequestedPlatformData()
{
var platforms = new List<SaucePlatform>
{
//Emulated Mobile Platforms
new AndroidPlatform("Google Pixel 8 Pro GoogleAPI Emulator", "15.0", SauceryConstants.DEVICE_ORIENTATION_PORTRAIT),
new IOSPlatform("iPhone 14 Pro Max Simulator", "16.2", SauceryConstants.DEVICE_ORIENTATION_LANDSCAPE),

//Desktop Platforms
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_11, SauceryConstants.BROWSER_CHROME, "123"),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_CHROME, "124", SauceryConstants.SCREENRES_2560_1600)
};

SetPlatforms(platforms);
}

public static List<Func<BrowserVersion>> AllPlatforms() => GetAllPlatformsAsFunc();
public static List<BrowserVersion> AllPlatformsAsList() => GetAllPlatformsAsList();
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 12th July 2024
*
*/
2 changes: 1 addition & 1 deletion Merlin.TUnit.RealDevices/ClickLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task ClickLinkTest(BrowserVersion requestedPlatform)
guineaPigPage.ClickLink(SauceryDriver());

// verify the browser was navigated to the correct page
Driver!.Url.ShouldContain("saucelabs.com/test-guinea-pig2.html");
await Assert.That(Driver!.Url).Contains("saucelabs.com/test-guinea-pig2.html");
}
}
/*
Expand Down
21 changes: 10 additions & 11 deletions Merlin.TUnit.RealDevices/DataDrivenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ namespace Merlin.TUnit.RealDevices;
public class DataDrivenTests : SauceryTBase
{
[Test]
[MethodDataSource(nameof(AllCombinations), Arguments = [ new[] { 4, 5 } ])]
[MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])]
public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);

var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");

guineaPigPage.TypeField(SauceryDriver(), "comments", data.ToString());
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data)
{
foreach (var browserVersion in RequestedPlatformData.AllPlatformsAsList())
{
foreach (var datum in data)
{
yield return (browserVersion, datum);
}
}
var commentField = guineaPigPage.GetField(SauceryDriver(), "comments");
await Assert.That(commentField).IsNotNull();

var commentText = commentField.GetDomProperty("value");
await Assert.That(commentText).Contains(data.ToString());
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList()
from datum in data
select (browserVersion, datum);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion Merlin.TUnit.RealDevices/Merlin.TUnit.RealDevices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="TUnit" Version="0.5.6" />
<PackageReference Include="TUnit" Version="0.5.22" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Merlin.TUnit/ClickLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task ClickLinkTest(BrowserVersion requestedPlatform)
guineaPigPage.ClickLink(SauceryDriver());

// verify the browser was navigated to the correct page
Driver!.Url.ShouldContain("saucelabs.com/test-guinea-pig2.html");
await Assert.That(Driver!.Url).Contains("saucelabs.com/test-guinea-pig2.html");
}
}
/*
Expand Down
Loading

0 comments on commit d3f9a6f

Please sign in to comment.