Skip to content

Commit b29e292

Browse files
authored
Merge pull request #249 from phlorian/feature/gh-246
(GH-246) Add alias for GetTestRuns method on AzureDevOpsbuild class
2 parents dd8a5e4 + b354944 commit b29e292

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/Cake.AzureDevOps/AzureDevOpsAliases.Pipelines.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,5 +351,53 @@ public static IEnumerable<AzureDevOpsBuildArtifact> AzureDevOpsBuildArtifacts(
351351
new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory())
352352
.GetArtifacts();
353353
}
354+
355+
/// <summary>
356+
/// Gets the test runs for an Azure Pipelines build.
357+
/// </summary>
358+
/// <param name="context">The context.</param>
359+
/// <param name="settings">Settings for getting the build.</param>
360+
/// <example>
361+
/// <para>Get test runs for an Azure Pipelines build:</para>
362+
/// <code>
363+
/// <![CDATA[
364+
/// var buildSettings =
365+
/// new AzureDevOpsBuildSettings(
366+
/// new Uri("http://myserver:8080/defaultcollection"),
367+
/// "MyProject",
368+
/// 42,
369+
/// AzureDevOpsAuthenticationNtlm());
370+
///
371+
/// var testRuns =
372+
/// AzureDevOpsBuildTestRuns(
373+
/// buildSettings);
374+
///
375+
/// Information("Test runs:");
376+
/// foreach (var testRun in testRuns)
377+
/// {
378+
/// Information(" {0}: {1}", testRun.RunId, testRun.TestResults.Count());
379+
/// }
380+
/// ]]>
381+
/// </code>
382+
/// </example>
383+
/// <returns>Test runs for the build.
384+
/// Returns an empty list if build could not be found and
385+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns>
386+
/// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
387+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
388+
[CakeMethodAlias]
389+
[CakeAliasCategory("Azure Pipelines")]
390+
[CakeNamespaceImport("Cake.AzureDevOps.Pipelines")]
391+
public static IEnumerable<AzureDevOpsTestRun> AzureDevOpsBuildTestRuns(
392+
this ICakeContext context,
393+
AzureDevOpsBuildSettings settings)
394+
{
395+
context.NotNull(nameof(context));
396+
settings.NotNull(nameof(settings));
397+
398+
return
399+
new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory())
400+
.GetTestRuns();
401+
}
354402
}
355403
}

0 commit comments

Comments
 (0)