Skip to content

Commit

Permalink
add Microsoft.Diagnostics.NETCore.Client package
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertk committed Oct 27, 2023
1 parent eb46e9a commit 9162fa4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageVersion Include="Microsoft.Build.Framework" Version="17.5.0"/>
<PackageVersion Include="Microsoft.Build.Locator" Version="1.5.5" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
<PackageVersion Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.452401" />
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
Expand Down
1 change: 1 addition & 0 deletions src/coverlet.collector/coverlet.collector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" />
<PackageReference Include="NuGet.Frameworks" />
</ItemGroup>
Expand Down
62 changes: 39 additions & 23 deletions test/coverlet.integration.tests/Msbuild.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Toni Solarin-Sodara
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.IO;
using System.Linq;
using Xunit;
Expand Down Expand Up @@ -32,8 +33,8 @@ public void TestMsbuild()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);
Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "coverage.json")));
AssertCoverage(clonedTemplateProject);
}
Expand All @@ -44,7 +45,7 @@ public void TestMsbuild_NoCoverletOutput()
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);
Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "coverage.json")));
AssertCoverage(clonedTemplateProject);
}
Expand All @@ -54,8 +55,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithoutExtension()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);
Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.json")));
AssertCoverage(clonedTemplateProject, "file.json");
}
Expand All @@ -65,8 +66,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);
Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext")));
AssertCoverage(clonedTemplateProject, "file.ext");
}
Expand All @@ -78,8 +79,16 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension_SpecifyFramework
Assert.False(clonedTemplateProject.IsMultipleTargetFramework());
string framework = clonedTemplateProject.GetTargetFrameworks().Single();
Assert.True(DotnetCli($"test -c {_buildConfiguration} -f {framework} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
if (!string.IsNullOrEmpty(standardError))
{
_output.WriteLine(standardError);
}
else
{
_output.WriteLine(standardOutput);
}
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);
Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext")));
AssertCoverage(clonedTemplateProject, "file.ext");
}
Expand All @@ -89,8 +98,15 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithDoubleExtension()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext1.ext2", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
if (!string.IsNullOrEmpty(standardError))
{
_output.WriteLine(standardError);
} else
{
_output.WriteLine(standardOutput);
}
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);
Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext1.ext2")));
AssertCoverage(clonedTemplateProject, "file.ext1.ext2");
}
Expand All @@ -102,8 +118,8 @@ public void Test_MultipleTargetFrameworkReport_NoCoverletOutput()
string[] targetFrameworks = new string[] { "net6.0", "net7.0" };
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);

foreach (string targetFramework in targetFrameworks)
{
Expand All @@ -125,8 +141,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder()
_output.WriteLine(standardError);
}
Assert.True(result);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);

foreach (string targetFramework in targetFrameworks)
{
Expand All @@ -144,8 +160,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
string[] targetFrameworks = new string[] { "net6.0", "net7.0" };
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);

foreach (string targetFramework in targetFrameworks)
{
Expand All @@ -166,8 +182,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
Assert.Equal(2, frameworks.Length);
string framework = frameworks.FirstOrDefault()!;
Assert.True(DotnetCli($"test -c {_buildConfiguration} -f {framework} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);

foreach (string targetFramework in targetFrameworks)
{
Expand All @@ -191,8 +207,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
string[] targetFrameworks = new string[] { "net6.0", "net7.0" };
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);

foreach (string targetFramework in targetFrameworks)
{
Expand All @@ -209,8 +225,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
string[] targetFrameworks = new string[] { "net6.0", "net7.0" };
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext1.ext2", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput);
Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal);
Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal);

foreach (string targetFramework in targetFrameworks)
{
Expand Down

0 comments on commit 9162fa4

Please sign in to comment.