Skip to content

Commit

Permalink
add locks
Browse files Browse the repository at this point in the history
  • Loading branch information
agray committed Jan 21, 2025
1 parent fb0cddc commit 7339e21
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
9 changes: 8 additions & 1 deletion Saucery.Core/Dojo/BrowserVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@ private void AppendPlatformField(string fieldToAdd)
{
lock (TestNameBuilder)
{
TestNameBuilder.Append($"{SauceryConstants.UNDERSCORE}{fieldToAdd}");
if (TestNameBuilder.Length == 0)
{
TestNameBuilder.Append($"{fieldToAdd}");
}
else
{
TestNameBuilder.Append($"{SauceryConstants.UNDERSCORE}{fieldToAdd}");
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions Saucery.Playwright.NUnit/SauceryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ protected SauceryBase(BrowserVersion browserVersion) =>
[SetUp]
public void Setup()
{
_browserVersion!.SetTestName(TestContext.CurrentContext.Test.Name);
_testName = _browserVersion.TestName!;
lock(_browserVersion!) {
_browserVersion!.SetTestName(TestContext.CurrentContext.Test.Name);
_testName = _browserVersion.TestName!;
}

//DebugMessages.PrintPlatformDetails(platform);
// set up the desired options
Expand Down
7 changes: 5 additions & 2 deletions Saucery.TUnit/SauceryTBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ public class SauceryTBase : BaseFixture
protected bool InitialiseDriver(BrowserVersion browserVersion)
{
_browserVersion = browserVersion;
_browserVersion.SetTestName(GetTestName());
_testName = _browserVersion.TestName;
lock (browserVersion)
{
_browserVersion.SetTestName(GetTestName());
_testName = _browserVersion.TestName;
}

//DebugMessages.PrintPlatformDetails(platform);
// set up the desired options
Expand Down
8 changes: 6 additions & 2 deletions Saucery.XUnit/SauceryXBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public class SauceryXBase : XunitContextBase, IClassFixture<BaseFixture>
protected bool InitialiseDriver(BrowserVersion browserVersion)
{
_browserVersion = browserVersion;
_browserVersion.SetTestName(GetTestName());
_testName = _browserVersion.TestName;

lock (_browserVersion)
{
_browserVersion.SetTestName(GetTestName());
_testName = _browserVersion.TestName;
}

//DebugMessages.PrintPlatformDetails(platform);
// set up the desired options
Expand Down
7 changes: 5 additions & 2 deletions Saucery/SauceryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ protected SauceryBase(BrowserVersion browserVersion) : this() =>
[SetUp]
public void Setup()
{
_browserVersion?.SetTestName(TestContext.CurrentContext.Test.Name);
_testName = _browserVersion?.TestName;
lock (_browserVersion!)
{
_browserVersion?.SetTestName(TestContext.CurrentContext.Test.Name);
_testName = _browserVersion?.TestName;
}

//DebugMessages.PrintPlatformDetails(platform);
// set up the desired options
Expand Down

0 comments on commit 7339e21

Please sign in to comment.