Skip to content

Commit

Permalink
(#46) Add support for importing unit test results
Browse files Browse the repository at this point in the history
This "could" be done as a build step in the settings.kts file, but this
is better done as part of the buid script.

That way, things can be more easily changed, if/when required.
  • Loading branch information
gep13 committed May 4, 2022
1 parent f33db17 commit da08225
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Chocolatey.Cake.Recipe/Content/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public class Builder
BuildParameters.Tasks.GenerateLocalCoverageReportTask.IsDependentOn("Test-xUnit");
BuildParameters.Tasks.TestTask.IsDependentOn("Generate-FriendlyTestReport");
BuildParameters.Tasks.TestTask.IsDependentOn("Generate-LocalCoverageReport");
BuildParameters.Tasks.TestTask.IsDependentOn("Report-UnitTestResults");
BuildParameters.Tasks.TestTask.IsDependentOn("Report-Code-Coverage-Metrics");
}
else
Expand All @@ -544,6 +545,7 @@ public class Builder
BuildParameters.Tasks.PackageTask.IsDependentOn(prefix + "Pack");
BuildParameters.Tasks.GenerateLocalCoverageReportTask.IsDependentOn(prefix + "Test");
BuildParameters.Tasks.TestTask.IsDependentOn("Generate-LocalCoverageReport");
BuildParameters.Tasks.TestTask.IsDependentOn("Report-UnitTestResults");
BuildParameters.Tasks.TestTask.IsDependentOn("Report-Code-Coverage-Metrics");
}
}
Expand Down
1 change: 1 addition & 0 deletions Chocolatey.Cake.Recipe/Content/tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class BuildTasks
public CakeTaskBuilder TestxUnitTask { get; set; }
public CakeTaskBuilder DotNetCoreTestTask { get; set; }
public CakeTaskBuilder GenerateFriendlyTestReportTask { get; set; }
public CakeTaskBuilder ReportUnitTestResultsTask { get; set; }
public CakeTaskBuilder ReportCodeCoverageMetricsTask { get; set; }
public CakeTaskBuilder GenerateLocalCoverageReportTask { get; set; }
public CakeTaskBuilder TestTask { get; set; }
Expand Down
18 changes: 18 additions & 0 deletions Chocolatey.Cake.Recipe/Content/testing.cake
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,24 @@ BuildParameters.Tasks.GenerateFriendlyTestReportTask = Task("Generate-FriendlyTe
})
);

BuildParameters.Tasks.ReportUnitTestResultsTask = Task("Report-UnitTestResults")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildSystem.IsRunningOnTeamCity, "Skipping due to not running on TeamCity")
.Does(() => {
Information("Reporting Unit Test results to TeamCity if any exist...");
foreach (var xUnitResultFile in GetFiles(BuildParameters.Paths.Directories.xUnitTestResults + "/*.xml"))
{
Information("Reporting XUnit file: {0}", xUnitResultFile);
TeamCity.ImportData("xunit", xUnitResultFile);
}

foreach (var nUnitResultFile in GetFiles(BuildParameters.Paths.Directories.NUnitTestResults + "/*.xml"))
{
Information("Reporting NUnit file: {0}", nUnitResultFile);
TeamCity.ImportData("nunit", nUnitResultFile);
}
});

BuildParameters.Tasks.ReportCodeCoverageMetricsTask = Task("Report-Code-Coverage-Metrics")
.WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial")
.WithCriteria(() => BuildSystem.IsRunningOnTeamCity, "Skipping due to not running on TeamCity")
Expand Down

0 comments on commit da08225

Please sign in to comment.