diff --git a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/api/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.netstandard2.0.cs b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/api/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.netstandard2.0.cs
index 4c4c2fb4de3f2..c021a18ed9caa 100644
--- a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/api/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.netstandard2.0.cs
+++ b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/api/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.netstandard2.0.cs
@@ -32,6 +32,7 @@ public partial class RunSettingKey
public static readonly string NumberOfTestWorkers;
public static readonly string Os;
public static readonly string RunId;
+ public static readonly string RunName;
public static readonly string ServiceAuthType;
public static readonly string UseCloudHostedBrowsers;
public RunSettingKey() { }
diff --git a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Constants.cs b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Constants.cs
index 6eee7b7d13f34..70bf02cc78e87 100644
--- a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Constants.cs
+++ b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Constants.cs
@@ -185,6 +185,11 @@ public class RunSettingKey
/// Number of NUnit test workers.
///
public static readonly string NumberOfTestWorkers = "NumberOfTestWorkers";
+
+ ///
+ /// The run name setting key.
+ ///
+ public static readonly string RunName = "RunName";
}
internal class Constants
diff --git a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Model/CloudRunMetadata.cs b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Model/CloudRunMetadata.cs
index 4e4f419248512..0539dcb4ee6b2 100644
--- a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Model/CloudRunMetadata.cs
+++ b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Model/CloudRunMetadata.cs
@@ -9,6 +9,7 @@ internal class CloudRunMetadata
{
internal string? WorkspaceId { get; set; }
internal string? RunId { get; set; }
+ internal string? RunName { get; set; }
internal Uri? BaseUri { get; set; }
internal string? PortalUrl
{
diff --git a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/PlaywrightReporter.cs b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/PlaywrightReporter.cs
index 670b5a5aa1bfd..6e95fe0aead7b 100644
--- a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/PlaywrightReporter.cs
+++ b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/PlaywrightReporter.cs
@@ -101,6 +101,8 @@ internal void InitializePlaywrightReporter(string xmlSettings)
runParameters.TryGetValue(RunSettingKey.EnableGitHubSummary, out var enableGithubSummary);
runParameters.TryGetValue(RunSettingKey.EnableResultPublish, out var enableResultPublish);
nunitParameters.TryGetValue(RunSettingKey.NumberOfTestWorkers, out var numberOfTestWorkers);
+ runParameters.TryGetValue(RunSettingKey.RunName, out var runName);
+
string? enableGithubSummaryString = enableGithubSummary?.ToString();
string? enableResultPublishString = enableResultPublish?.ToString();
@@ -148,6 +150,7 @@ internal void InitializePlaywrightReporter(string xmlSettings)
var cloudRunMetadata = new CloudRunMetadata
{
RunId = cloudRunId,
+ RunName = runName?.ToString(),
WorkspaceId = workspaceId,
BaseUri = baseUri,
EnableResultPublish = _enableResultPublish,
diff --git a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Processor/DataProcessor.cs b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Processor/DataProcessor.cs
index 86d836e9783e0..06ce4d40041f7 100644
--- a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Processor/DataProcessor.cs
+++ b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Processor/DataProcessor.cs
@@ -29,7 +29,19 @@ public TestRunDto GetTestRun()
{
var startTime = _cloudRunMetadata.TestRunStartTime.ToString("yyyy-MM-ddTHH:mm:ssZ");
var gitBasedRunName = ReporterUtils.GetRunName(CiInfoProvider.GetCIInfo())?.Trim();
- string runName = string.IsNullOrEmpty(gitBasedRunName) ? _cloudRunMetadata.RunId! : gitBasedRunName!;
+ string runName;
+ if (!string.IsNullOrEmpty(_cloudRunMetadata.RunName))
+ {
+ runName = _cloudRunMetadata.RunName!;
+ }
+ else if (!string.IsNullOrEmpty(gitBasedRunName))
+ {
+ runName = gitBasedRunName!;
+ }
+ else
+ {
+ runName = _cloudRunMetadata.RunId!;
+ }
var run = new TestRunDto
{
TestRunId = _cloudRunMetadata.RunId!,
diff --git a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/tests/Processor/DataProcessorTests.cs b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/tests/Processor/DataProcessorTests.cs
index 2964243098888..279022ff687da 100644
--- a/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/tests/Processor/DataProcessorTests.cs
+++ b/sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/tests/Processor/DataProcessorTests.cs
@@ -5,6 +5,7 @@
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Processor;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Utility;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+using Moq;
namespace Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Tests.Processor
{
@@ -68,6 +69,32 @@ public void GetTestRun_ReturnsTestRunDto()
Assert.IsNotNull(result.TestRunConfig!.Shards);
Assert.AreEqual(1, result.TestRunConfig!.Shards!.Total);
}
+ [Test]
+ public void GetTestRun_ShouldUseRunName_WhenRunNameIsNotEmpty()
+ {
+ var cloudRunMetadata = new CloudRunMetadata
+ {
+ RunName = "runName",
+ WorkspaceId = "workspaceId",
+ RunId = "runId",
+ AccessTokenDetails = new()
+ {
+ oid = "oid",
+ userName = " userName "
+ }
+ };
+ var cIInfo = new CIInfo
+ {
+ Branch = "branch_name",
+ Author = "author",
+ CommitId = "commitId",
+ RevisionUrl = "revisionUrl",
+ Provider = CIConstants.s_gITHUB_ACTIONS
+ };
+ var dataProcessor = new DataProcessor(cloudRunMetadata, cIInfo);
+ TestRunDto result = dataProcessor.GetTestRun();
+ Assert.AreEqual("runName", result.DisplayName);
+ }
[Test]
public void GetTestRunShard_ReturnsTestRunShardDto()
@@ -151,7 +178,58 @@ public void GetTestCaseResultData_WithNonNullTestResult_ReturnsTestResults()
Assert.AreEqual(TestCaseResultStatus.s_iNCONCLUSIVE, result.ResultsSummary.Status);
Assert.AreEqual(TestCaseResultStatus.s_iNCONCLUSIVE, result.Status);
}
-
+ [Test]
+ [Ignore("Need to mock GetRunName response")]
+ public void GetTestRun_ShouldUseGitBasedRunName_WhenRunNameIsEmptyAndGitBasedRunNameIsNotEmpty()
+ {
+ var cloudRunMetadata = new CloudRunMetadata
+ {
+ RunName = "",
+ WorkspaceId = "workspaceId",
+ RunId = "runId",
+ AccessTokenDetails = new()
+ {
+ oid = "oid",
+ userName = " userName "
+ }
+ };
+ var cIInfo = new CIInfo
+ {
+ Branch = "branch_name",
+ Author = "author",
+ CommitId = "commitId",
+ RevisionUrl = "revisionUrl",
+ Provider = CIConstants.s_gITHUB_ACTIONS
+ };
+ var gitBasedRunName = ReporterUtils.GetRunName(cIInfo);
+ var dataProcessor = new DataProcessor(cloudRunMetadata, cIInfo);
+ TestRunDto result = dataProcessor.GetTestRun();
+ Assert.AreEqual(gitBasedRunName, result.DisplayName);
+ }
+ [Test]
+ [Ignore("Need to mock GetRunName response")]
+ public void GetTestRun_ShouldUseRunId_WhenRunNameAndGitBasedRunNameAreEmpty()
+ {
+ var cloudRunMetadata = new CloudRunMetadata
+ {
+ RunName = "",
+ WorkspaceId = "workspaceId",
+ RunId = "runId",
+ AccessTokenDetails = new()
+ {
+ oid = "oid",
+ userName = " userName "
+ }
+ };
+ var cIInfo = new CIInfo
+ {
+ };
+ var reporterUtilsMock = new Mock();
+ reporterUtilsMock.Setup(r => ReporterUtils.GetRunName(cIInfo)).Returns(string.Empty);
+ var dataProcessor = new DataProcessor(cloudRunMetadata, cIInfo);
+ TestRunDto result = dataProcessor.GetTestRun();
+ Assert.AreEqual("runId", result.DisplayName);
+ }
[Test]
public void GetRawResultObject_WithNullTestResult_ReturnsRawTestResultWithEmptyErrorsAndStdErr()
{