@@ -351,5 +351,53 @@ public static IEnumerable<AzureDevOpsBuildArtifact> AzureDevOpsBuildArtifacts(
351
351
new AzureDevOpsBuild ( context . Log , settings , new BuildClientFactory ( ) )
352
352
. GetArtifacts ( ) ;
353
353
}
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
+ }
354
402
}
355
403
}
0 commit comments