Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COLDFIX] Unit Test Target Not Producing Xml Files #21

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added execution of `IPublish.Publish` target on `integration` workflow
- Added `IHaveReport` component that can be used by pipelines that output reports of any kind (code coverage, performance tests, ...)
- Added `IUnitTest.UnitTestsResultsDirectory` which defines where to output unit test result files
- Added `IUnitTest.ProjectUnitTestSettings` to customize/override the unit tests settings.
- Added `IMutationTest.MutationTestResultsDirectory` which defines where to output mutation test result files
- Added `IBenchmark.BenchmarkTestResultsDirectory` which defines where to output benchmarks test result files
- Added `IPullRequest` component which extends `IGitFlow` and create pull requests instead or merging back to `develop` (respectiveley `main`) when finishing a feature / coldfix (resp. release / hotfix) branch.
Expand Down
22 changes: 16 additions & 6 deletions src/Candoumbe.Pipelines/Components/IUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Nuke.Common.Tools.Coverlet;
using Nuke.Common.Tools.DotNet;

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -47,11 +48,9 @@ public interface IUnitTest : ICompile, IHaveTests, IHaveCoverage
.Apply(UnitTestSettingsBase)
.Apply(UnitTestSettings)
.CombineWith(UnitTestsProjects, (cs, project) => cs.SetProjectFile(project)
.CombineWith(project.GetTargetFrameworks(), (setting, framework) => setting.SetFramework(framework)
.AddLoggers($"trx;LogFileName={project.Name}.trx")
.SetCoverletOutput(UnitTestResultsDirectory / $"{project.Name}.{framework}.xml"))),
completeOnFailure: true
);
.CombineWith(project.GetTargetFrameworks(), (setting, framework) => setting.Apply<DotNetTestSettings, (Project, string)>(ProjectUnitTestSettingsBase, (project, framework))
.Apply<DotNetTestSettings, (Project, string)>(ProjectUnitTestSettings, (project, framework))
)));

TestResultDirectory.GlobFiles("*.trx")
.ForEach(testFileResult => AzurePipelines.Instance?.PublishTestResults(type: AzurePipelinesTestResultsType.VSTest,
Expand Down Expand Up @@ -79,4 +78,15 @@ public interface IUnitTest : ICompile, IHaveTests, IHaveCoverage
/// Configures the Unit test target
/// </summary>
public Configure<DotNetTestSettings> UnitTestSettings => _ => _;
}


internal Configure<DotNetTestSettings, (Project project, string framework)> ProjectUnitTestSettingsBase => (settings, tuple) => settings.SetFramework(tuple.framework)
.AddLoggers($"trx;LogFileName={tuple.project.Name}.{tuple.framework}.trx")
.SetCoverletOutput(UnitTestResultsDirectory / $"{tuple.project.Name}.{tuple.framework}.xml");

/// <summary>
/// Configure / override unit test settings at project level
/// </summary>
Configure<DotNetTestSettings, (Project project, string framework)> ProjectUnitTestSettings => (settings, tuple) => settings;

}