From 16106891c636c9687bf476328783c92b6af3c522 Mon Sep 17 00:00:00 2001 From: "Dylan R. E. Moonfire" Date: Mon, 29 Nov 2021 22:24:20 -0600 Subject: [PATCH] ci: working on code coverage --- .gitlab-ci.yml | 2 +- .../SampleToolTests.cs | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8db9b4..2a1b2db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/tests/MfGames.ToolBuilder.Tests/SampleToolTests.cs b/tests/MfGames.ToolBuilder.Tests/SampleToolTests.cs index 61c7388..d09e3f1 100644 --- a/tests/MfGames.ToolBuilder.Tests/SampleToolTests.cs +++ b/tests/MfGames.ToolBuilder.Tests/SampleToolTests.cs @@ -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( - async () => await Cli.Wrap("dotnet") - .WithArguments( - new[] - { - "run", "--project", projectFile.FullName, "--", - "crash", - }) - .WithWorkingDirectory(projectFile.DirectoryName!) - .WithStandardOutputPipe(PipeTarget.ToStringBuilder(output)) - .ExecuteAsync(cancellationToken) - .ConfigureAwait(false)); + Task exception = + Assert.ThrowsAsync( + 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);