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,7 +27,8 @@ namespace MfGames.ToolBuilder.Tests
new CancellationTokenSource(TimeSpan.FromSeconds(20)) new CancellationTokenSource(TimeSpan.FromSeconds(20))
.Token; .Token;
var exception = Assert.ThrowsAsync<CommandExecutionException>( Task<CommandExecutionException> exception =
Assert.ThrowsAsync<CommandExecutionException>(
async () => await Cli.Wrap("dotnet") async () => await Cli.Wrap("dotnet")
.WithArguments( .WithArguments(
new[] new[]
@ -36,7 +37,8 @@ namespace MfGames.ToolBuilder.Tests
"crash", "crash",
}) })
.WithWorkingDirectory(projectFile.DirectoryName!) .WithWorkingDirectory(projectFile.DirectoryName!)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(output)) .WithStandardOutputPipe(
PipeTarget.ToStringBuilder(output))
.ExecuteAsync(cancellationToken) .ExecuteAsync(cancellationToken)
.ConfigureAwait(false)); .ConfigureAwait(false));