Skip to content

Commit

Permalink
add external tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agray committed Dec 21, 2024
1 parent d19540c commit fdd42fe
Show file tree
Hide file tree
Showing 20 changed files with 341 additions and 119 deletions.
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
Driver!.Url.ShouldContain("saucelabs.com/test-guinea-pig2.html");
}
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
38 changes: 38 additions & 0 deletions ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);

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

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

return Task.CompletedTask;
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data)
{
foreach (var browserVersion in RequestedPlatformData.AllPlatformsAsList())
{
foreach (var datum in data)
{
yield return (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;
}
34 changes: 34 additions & 0 deletions ExternalMerlin.TUnit.RealDevices/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.RealDevices;

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
*
*/
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
Driver!.Url.ShouldContain("saucelabs.com/test-guinea-pig2.html");
}
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
36 changes: 36 additions & 0 deletions ExternalMerlin.TUnit/DataDrivenTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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());
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data)
{
foreach (var browserVersion in RequestedPlatformData.AllPlatformsAsList())
{
foreach (var datum in data)
{
yield return (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
*
*/
6 changes: 4 additions & 2 deletions Merlin.TUnit.RealDevices/DataDrivenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ namespace Merlin.TUnit.RealDevices;
public class DataDrivenTests : SauceryTBase
{
[Test]
[MethodDataSource(nameof(AllCombinations), Arguments = [ new[] { 4, 5 } ])]
public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
[MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])]
public Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);

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

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

return Task.CompletedTask;
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data)
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
6 changes: 4 additions & 2 deletions Merlin.TUnit/DataDrivenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ namespace Merlin.TUnit;
public class DataDrivenTests : SauceryTBase
{
[Test]
[MethodDataSource(nameof(AllCombinations), Arguments = [ new[] { 4, 5 } ])]
public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
[MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])]
public Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);

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

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

return Task.CompletedTask;
}

public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data)
Expand Down
2 changes: 1 addition & 1 deletion Merlin.TUnit/Merlin.TUnit.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 Sandbox.TUnit/Sandbox.TUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.13.1" />
<PackageReference Include="TUnit" Version="0.5.6" />
<PackageReference Include="TUnit" Version="0.5.22" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion Saucery.Core/DataSources/SauceryTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;
using System.Collections;
using System.Linq;

namespace Saucery.Core.DataSources;

Expand Down
Loading

0 comments on commit fdd42fe

Please sign in to comment.