Skip to content

Commit 7bc94e5

Browse files
authored
Print DotNet Test Results even if successful (#236)
* Print DotNet Test Results even if successful * Formatting Markdown --------- Co-authored-by: Tom Longhurst <thomhurst@users.noreply.github.com>
1 parent a09819e commit 7bc94e5

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Execution and Dependencies](getting-started/execution-and-dependencies "Execution and Dependencies")
1111
- [Sharing data across modules](getting-started/sharing-data "Sharing Data amongst Modules")
1212
- [Storing and Retrieving Results](getting-started/storing-and-retrieving-results "Storing and Retrieving Results")
13+
- [Custom commands](getting-started/custom-commands "Custom commands")
1314
- [Analyzers](getting-started/analyzers "Analyzers")
1415
- [Logging](getting-started/logging "Logging")
1516
- [Secrets](getting-started/secrets "Secrets")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Custom commands
2+
Many common CLI tools, such as npm, yarn, dotnet, docker, kubectl, have all had strong objects created to wrap around their CLI commands.
3+
4+
If you want to run a command that isn't currently supported by strong objects, you can still run commands directly through the `ICommand` interface available on the `context` object within your modules.
5+
6+
Every argument should be passed as a separate string in a collection. This allows proper formatting if there's things like spaces or quotes.
7+
8+
## Example
9+
10+
```csharp
11+
await context.Command.ExecuteCommandLineTool(new CommandLineToolOptions("dotnet")
12+
{
13+
Arguments = new[] { "tool", "install", "--global", "dotnet-coverage" },
14+
}, cancellationToken);
15+
```
16+
17+
This is the equivalent to running:
18+
19+
`dotnet tool install --global dotnet-coverage`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
null
1+
* Print DotNet Test results if successful

src/ModularPipelines.DotNet/DotNet.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics.CodeAnalysis;
22
using Microsoft.Extensions.Logging;
33
using ModularPipelines.Context;
4+
using ModularPipelines.DotNet.Enums;
45
using ModularPipelines.DotNet.Exceptions;
56
using ModularPipelines.DotNet.Options;
67
using ModularPipelines.Extensions;
@@ -86,6 +87,12 @@ public async Task<DotNetTestResult> Test(DotNetTestOptions options, Cancellation
8687
throw new DotNetTestFailedException(result, parsedTestResults);
8788
}
8889

90+
var success = parsedTestResults.UnitTestResults.Count(x => x.Outcome == TestOutcome.Passed);
91+
var failed = parsedTestResults.UnitTestResults.Count(x => x.Outcome == TestOutcome.Failed);
92+
var skipped = parsedTestResults.UnitTestResults.Count(x => x.Outcome == TestOutcome.NotExecuted);
93+
94+
logger.LogInformation("DotNet Test Results - Success: {Success} - Failed: {Failed} - Skipped: {Skipped}", success, failed, skipped);
95+
8996
return parsedTestResults;
9097
}
9198

0 commit comments

Comments
 (0)