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 new tool-manifest
- 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
artifacts:
when: always

View file

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