Saucery 4.4.3
Prefix ReservedSee the version list below for details.
dotnet add package Saucery --version 4.4.3
NuGet\Install-Package Saucery -Version 4.4.3
<PackageReference Include="Saucery" Version="4.4.3" />
paket add Saucery --version 4.4.3
#r "nuget: Saucery, 4.4.3"
// Install Saucery as a Cake Addin #addin nuget:?package=Saucery&version=4.4.3 // Install Saucery as a Cake Tool #tool nuget:?package=Saucery&version=4.4.3
<h1 align="center">
<img src="https://raw.githubusercontent.com/SauceForge/Saucery/master/Saucery.Core/Images/Saucery.Core.png" alt="Saucery" width="200"/> <br/> Saucery </h1>
<div align="center">
<b>Automated testing made more awesome</b>
</div>
Saucery handles all the plumbing required to integrate with SauceLabs, making writing tests a breeze. Saucery comes in multiple flavors supporting popular test frameworks.
Dog food Status
We test Saucery itself on SauceLabs!
Getting Started
Saucery takes care of the plumbing required to talk to SauceLabs, so you only need to tell Saucery what you want. Saucery takes care of the how.
Your tests, of course, will be specific to your System Under Test. The ones specified below are only provided as examples only.
Initial Setup
These steps apply to all flavors:
- You'll need a SauceLabs account. You can get a free trial account here.
- If you want to run your tests locally you need to set 2 environment variables, SAUCE_USER_NAME and SAUCE_API_KEY
- To run your test suite from your GitHub Actions pipeline you need to set two secrets SAUCE_USER_NAME and SAUCE_API_KEY. Instructions on how to set Gihub Secrets are here.
NUnit
- In your solution create a simple class library.
- Add a NuGet Reference to Saucery.
- Start with the following template:
using NUnit.Framework;
using Saucery;
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Shouldly;
[assembly: LevelOfParallelism(4)]
namespace ExternalMerlin.NUnit;
[TestFixture]
[Parallelizable]
[TestFixtureSource(typeof(RequestedPlatformData))]
public class NuGetIntegrationTests(BrowserVersion browserVersion) : SauceryBase(browserVersion)
{
[Test]
[TestCase(5)]
[TestCase(4)]
public void DataDrivenTitleTest(int data) {
var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");
guineaPigPage.TypeField(SauceryDriver(), "comments", data.ToString());
Driver?.Title.ShouldContain("I am a page title - Sauce Labs");
}
[Test]
public void ClickLinkTest() {
var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");
// find and click the link on the page
guineaPigPage.ClickLink(SauceryDriver());
// verify the browser was navigated to the correct page
Driver?.Url.ShouldContain("saucelabs.com/test-guinea-pig2.html");
}
}
The above code will run 3 unit tests (1 ClickLink test and 2 DataDrivenTitle tests) on all the platforms you specify, in parallel.
The Level of Parallelism is determined by the number of parallel threads you have paid for in your SauceLabs account.
We recommend 1 less than your limit. Our OpenSauce account has 5 so we specify 4 in our internal testing.
Parallism is optional so you can exclude the [assembly: LevelOfParallelism(4)]
and [Parallelizable]
lines if you wish.
The other lines are mandatory. Let's break the key lines down.
[TestFixture]
[Parallelizable]
[TestFixtureSource(typeof(RequestedPlatformData))]
public class NuGetIntegrationTests(BrowserVersion browserVersion) : SauceryBase(browserVersion)
You can call the class what you like but it must take a BrowserVersion
as a parameter and subclass SauceryBase
.
[TestFixtureSource(typeof(RequestedPlatformData))]
is how you tell Saucery what platforms you want to test on. You need to specify a class to do that. In this example its called RequestedPlatformData
but you can call it anything you like.
Let's look at what it should contain.
using Saucery.Core.DataSources;
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;
using Saucery.Core.Util;
namespace ExternalMerlin.NUnit;
public class RequestedPlatformData : SauceryTestData
{
static RequestedPlatformData()
{
List<SaucePlatform> platforms =
[
//Mobile Platforms
new IOSPlatform("iPhone 14 Pro Max Simulator", "16.2", SauceryConstants.DEVICE_ORIENTATION_LANDSCAPE),
//Desktop Platforms
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_11, SauceryConstants.BROWSER_CHROME, "75"),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_CHROME, "76", SauceryConstants.SCREENRES_2560_1600)
];
SetPlatforms(platforms);
}
}
The List<SaucePlatform>
is what you will specify. The rest of the class is mandatory. Check out SauceryConstants
for all the platform, browser and screenres enums.
XUnit
- In your solution create a simple class library.
- Add a NuGet Reference to Saucery.XUnit
- Start with the following template:
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.XUnit;
using Xunit.Abstractions;
[assembly: CollectionBehavior(MaxParallelThreads = 5)]
namespace ExternalMerlin.XUnit;
public class DataDrivenTests(ITestOutputHelper output, BaseFixture baseFixture) : SauceryXBase(output, baseFixture)
{
[Theory]
[MemberData(nameof(AllCombinations))]
public void DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
InitialiseDriver(requestedPlatform);
var guineaPigPage = new GuineaPigPage(BaseFixture.SauceryDriver(), "https://saucelabs.com/");
guineaPigPage.TypeField(BaseFixture.SauceryDriver(), "comments", data.ToString());
}
public static IEnumerable<object[]> AllCombinations => GetAllCombinations([4, 5]);
}
The above code will run 2 unit tests (2 DataDrivenTitle tests) on all the platforms you specify.
Parallelism in XUnit is currently achieved by having tests in multiple classes.
The Level of Parallelism is determined by the number of parallel threads you have paid for in your SauceLabs account.
Parallism is optional so you can exclude [assembly: CollectionBehavior(MaxParallelThreads = 5)]
lines if you wish. We recommend placing this line in a Usings.cs
as it will apply to all your TestFixtures.
Next, let's break down the key line.
public class DataDrivenTests(ITestOutputHelper output, BaseFixture baseFixture) : SauceryXBase(output, baseFixture)
Your class must subclass SauceryXBase
and pass an ITestOutputHelper
and a BaseFixture
. SauceryX will take care of the rest.
You need to specify a class to tell SauceryX what platforms you want to test on. In this example its called RequestedPlatformData
but you can call it anything you like.
Let's look at what it should contain.
using Saucery.Core.DataSources;
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;
using Saucery.Core.Util;
namespace ExternalMerlin.XUnit;
public class RequestedPlatformData : SauceryTestData
{
static RequestedPlatformData()
{
List<SaucePlatform> platforms =
[
//Mobile Platforms
new IOSPlatform("iPhone 14 Pro Max Simulator", "16.2", SauceryConstants.DEVICE_ORIENTATION_LANDSCAPE),
//Desktop Platforms
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_11, SauceryConstants.BROWSER_CHROME, "75"),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_CHROME, "76", SauceryConstants.SCREENRES_2560_1600)
];
SetPlatforms(platforms);
}
public static IEnumerable<object[]> AllPlatforms => GetAllPlatforms();
}
The List<SaucePlatform>
is what you will specify. The rest of the class is mandatory. Check out SauceryConstants
for all the platform, browser and screenres enums.
Flavors
Saucery
Saucery.XUnit
Resources
Download statistics
Trends
Contact
Author: Andrew Gray
Twitter: @agrayz
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Appium.WebDriver (>= 5.0.0-rc.2)
- Microsoft.NET.Test.Sdk (>= 17.8.0)
- NUnit (>= 4.0.1)
- NUnit3TestAdapter (>= 4.5.0)
- Saucery.Core (>= 4.4.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.5.6 | 507 | 9/26/2024 |
4.5.5 | 248 | 9/13/2024 |
4.5.4 | 366 | 8/1/2024 |
4.5.3 | 393 | 7/12/2024 |
4.5.2 | 152 | 7/10/2024 |
4.5.1 | 373 | 6/29/2024 |
4.5.0 | 178 | 6/25/2024 |
4.4.6 | 169 | 6/24/2024 |
4.4.5 | 175 | 6/23/2024 |
4.4.4 | 254 | 5/26/2024 |
4.4.3 | 600 | 12/16/2023 |
4.4.2 | 194 | 12/11/2023 |
4.4.1 | 86 | 12/11/2023 |
4.4.0 | 274 | 12/8/2023 |
4.3.0 | 221 | 11/18/2023 |
4.2.0 | 352 | 8/5/2023 |
4.1.1 | 407 | 3/25/2023 |
4.0.3 | 486 | 6/13/2022 |
ChangeLog:
v4.1.1
- Initial Release with dependency on Saucery.Core