ci: working on code coverage

This commit is contained in:
Dylan R. E. Moonfire 2021-11-29 22:24:20 -06:00
parent ebbde0bf15
commit 16106891c6
2 changed files with 16 additions and 14 deletions

View file

@ -30,7 +30,7 @@ test:
- 'dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" --collect:"XPlat Code Coverage"' - 'dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" --collect:"XPlat Code Coverage"'
- dotnet new tool-manifest - dotnet new tool-manifest
- dotnet tool install dotnet-reportgenerator-globaltool - dotnet tool install dotnet-reportgenerator-globaltool
- dotnet tool run reportgenerator -reports:src/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary" - dotnet tool run reportgenerator -reports:tests/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary"
- grep "Line coverage" coverage/Summary.txt - grep "Line coverage" coverage/Summary.txt
artifacts: artifacts:
when: always when: always

View file

@ -18,7 +18,7 @@ namespace MfGames.ToolBuilder.Tests
public class SampleToolTests public class SampleToolTests
{ {
[Fact] [Fact]
public async Task CrashCommandFails() public void CrashCommandFails()
{ {
// Run the executable using CliWrap. // Run the executable using CliWrap.
FileInfo projectFile = GetProjectFile(); FileInfo projectFile = GetProjectFile();
@ -27,18 +27,20 @@ namespace MfGames.ToolBuilder.Tests
new CancellationTokenSource(TimeSpan.FromSeconds(20)) new CancellationTokenSource(TimeSpan.FromSeconds(20))
.Token; .Token;
var exception = Assert.ThrowsAsync<CommandExecutionException>( Task<CommandExecutionException> exception =
async () => await Cli.Wrap("dotnet") Assert.ThrowsAsync<CommandExecutionException>(
.WithArguments( async () => await Cli.Wrap("dotnet")
new[] .WithArguments(
{ new[]
"run", "--project", projectFile.FullName, "--", {
"crash", "run", "--project", projectFile.FullName, "--",
}) "crash",
.WithWorkingDirectory(projectFile.DirectoryName!) })
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(output)) .WithWorkingDirectory(projectFile.DirectoryName!)
.ExecuteAsync(cancellationToken) .WithStandardOutputPipe(
.ConfigureAwait(false)); PipeTarget.ToStringBuilder(output))
.ExecuteAsync(cancellationToken)
.ConfigureAwait(false));
// Verify the return code. // Verify the return code.
Assert.NotNull(exception); Assert.NotNull(exception);