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

More Code Coverage #1820

Merged
merged 3 commits into from Feb 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Expand Up @@ -78,6 +78,7 @@
"ApiChecks",
"CalculateNugetVersion",
"Clean",
"CodeCoverage",
"Compile",
"Pack",
"Push",
Expand All @@ -100,6 +101,7 @@
"ApiChecks",
"CalculateNugetVersion",
"Clean",
"CodeCoverage",
"Compile",
"Pack",
"Push",
Expand Down
33 changes: 27 additions & 6 deletions Build/Build.cs
Expand Up @@ -115,13 +115,18 @@ class Build : NukeBuild
.DependsOn(Compile)
.Executes(() =>
{
Project[] projects = new[]
{
Solution.Specs.FluentAssertions_Specs,
Solution.Specs.FluentAssertions_Equivalency_Specs
};

if (EnvironmentInfo.IsWin)
{
Xunit2(s =>
{
IReadOnlyCollection<string> testAssemblies = GlobFiles(
Solution.Specs.FluentAssertions_Specs.Directory,
"bin/Debug/net47/*.Specs.dll");
IEnumerable<string> testAssemblies = projects
.SelectMany(project => GlobFiles(project.Directory, "bin/Debug/net47/*.Specs.dll"));

Assert.NotEmpty(testAssemblies.ToList());

Expand All @@ -132,20 +137,33 @@ class Build : NukeBuild
}

DotNetTest(s => s
.SetProjectFile(Solution.Specs.FluentAssertions_Specs)
.SetConfiguration("Debug")
.EnableNoBuild()
.SetDataCollector("XPlat Code Coverage")
.SetResultsDirectory(RootDirectory / "TestResults")
.CombineWith(
Solution.Specs.FluentAssertions_Specs.GetTargetFrameworks().Except(new[] { "net47" }),
(_, v) => _.SetFramework(v)));
projects,
(_, project) => _
.SetProjectFile(project)
.CombineWith(
project.GetTargetFrameworks().Except(new[] { "net47" }),
(_, framework) => _.SetFramework(framework)
)
)
);
});

Target CodeCoverage => _ => _
.DependsOn(TestFrameworks)
.DependsOn(UnitTests)
.Executes(() =>
{
ReportGenerator(s => s
.SetProcessToolPath(ToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net5.0"))
.SetTargetDirectory(RootDirectory / "TestResults" / "reports")
.AddReports(RootDirectory / "TestResults/**/coverage.cobertura.xml")
.AddReportTypes("HtmlInline_AzurePipelines_Dark", "lcov")
.SetClassFilters("-System.Diagnostics.CodeAnalysis.StringSyntaxAttribute")
.SetAssemblyFilters("+FluentAssertions"));

string link = RootDirectory / "TestResults" / "reports" / "index.html";
Expand Down Expand Up @@ -173,6 +191,8 @@ class Build : NukeBuild
DotNetTest(s => s
.SetConfiguration("Debug")
.EnableNoBuild()
.SetDataCollector("XPlat Code Coverage")
.SetResultsDirectory(RootDirectory / "TestResults")
.CombineWith(
testCombinations,
(_, v) => _.SetProjectFile(v.project).SetFramework(v.framework)));
Expand All @@ -187,6 +207,7 @@ class Build : NukeBuild
.DependsOn(ApiChecks)
.DependsOn(TestFrameworks)
.DependsOn(UnitTests)
.DependsOn(CodeCoverage)
.DependsOn(CalculateNugetVersion)
.Executes(() =>
{
Expand Down
3 changes: 3 additions & 0 deletions Tests/TestFrameworks/MSTestV2.Specs/MSTestV2.Specs.csproj
Expand Up @@ -9,6 +9,9 @@
<ProjectReference Include="..\..\..\Src\FluentAssertions\FluentAssertions.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
Expand Down
3 changes: 3 additions & 0 deletions Tests/TestFrameworks/MSpec.Specs/MSpec.Specs.csproj
Expand Up @@ -9,6 +9,9 @@
<ProjectReference Include="..\..\..\Src\FluentAssertions\FluentAssertions.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Machine.Specifications" Version="1.0.0" />
<PackageReference Include="Machine.Specifications.Runner.VisualStudio" Version="2.10.2" />
Expand Down
3 changes: 3 additions & 0 deletions Tests/TestFrameworks/NUnit3.Specs/NUnit3.Specs.csproj
Expand Up @@ -9,6 +9,9 @@
<ProjectReference Include="..\..\..\Src\FluentAssertions\FluentAssertions.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1">
Expand Down