Skip to content

Commit b5b365c

Browse files
committed
add OutputType property for tests
1 parent 64b8ac2 commit b5b365c

File tree

10 files changed

+60
-45
lines changed

10 files changed

+60
-45
lines changed

test/coverlet.collector.tests/coverlet.collector.tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<PropertyGroup>
55
<TargetFrameworks>net8.0</TargetFrameworks>
66
<IsPackable>false</IsPackable>
7+
<OutputType>Exe</OutputType>
78
</PropertyGroup>
89

910
<ItemGroup>
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
// Remember to use full name because adding new using directives change line numbers
1+
// Remember to use full name because adding new using directives change line numbers
22

33
namespace Coverlet.Core.Tests
44
{
5-
public class Issue_669_2
5+
public class Issue_669_2
6+
{
7+
private readonly System.Net.Http.HttpClient _httpClient = new System.Net.Http.HttpClient();
8+
9+
async public System.Threading.Tasks.ValueTask<System.Net.Http.HttpResponseMessage> SendRequest()
610
{
7-
private readonly System.Net.Http.HttpClient _httpClient = new System.Net.Http.HttpClient();
11+
using (var requestMessage = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, "https://www.google.it"))
12+
{
13+
return await _httpClient.SendAsync(requestMessage).ConfigureAwait(false);
14+
}
15+
}
16+
}
817

9-
async public System.Threading.Tasks.ValueTask<System.Net.Http.HttpResponseMessage> SendRequest()
10-
{
11-
using (var requestMessage = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, "https://www.google.it"))
12-
{
13-
return await _httpClient.SendAsync(requestMessage).ConfigureAwait(false);
14-
}
15-
}
18+
class Program
19+
{
20+
static void Main(string[] args)
21+
{
22+
//Console.WriteLine("Hello, World!");
1623
}
24+
}
1725
}

test/coverlet.core.tests.samples.netstandard/coverlet.core.tests.samples.netstandard.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<IsPackable>false</IsPackable>
55
<IsTestProject>false</IsTestProject>
66
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
7+
<OutputType>Exe</OutputType>
78
</PropertyGroup>
89

910
<ItemGroup>

test/coverlet.core.tests/coverlet.core.tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<MSBuildWarningsAsMessages>NU1702;NU1504;NU1008;NU1604</MSBuildWarningsAsMessages>
99
<!--For test TestInstrument_NetstandardAwareAssemblyResolver_PreserveCompilationContext-->
1010
<PreserveCompilationContext>true</PreserveCompilationContext>
11+
<OutputType>Exe</OutputType>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

test/coverlet.integration.tests/DeterministicBuild.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ public void Msbuild()
9191
string logFilename = $"{TestContext.Current.TestClass?.TestClassName}.{TestContext.Current.TestMethod?.MethodName}.binlog";
9292
CreateDeterministicTestPropsFile();
9393

94-
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} /p:DeterministicSourcePaths=true", out string standardOutput, out string standardError, _testProjectPath);
95-
if (!string.IsNullOrEmpty(standardError))
94+
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} /p:DeterministicSourcePaths=true", out string buildOutput, out string buildError, _testProjectPath);
95+
if (!string.IsNullOrEmpty(buildError))
9696
{
97-
_output.WriteLine(standardError);
97+
_output.WriteLine(buildError);
9898
}
9999
else
100100
{
101-
_output.WriteLine(standardOutput);
101+
_output.WriteLine(buildOutput);
102102
}
103-
Assert.Contains("Build succeeded.", standardOutput);
103+
Assert.Contains("Build succeeded.", buildOutput);
104104
string sourceRootMappingFilePath = Path.Combine(_testBinaryPath, _buildConfiguration.ToLowerInvariant(), "CoverletSourceRootsMapping_coverletsample.integration.determisticbuild");
105105
Assert.True(File.Exists(sourceRootMappingFilePath), $"File not found: {sourceRootMappingFilePath}");
106106
Assert.False(string.IsNullOrEmpty(File.ReadAllText(sourceRootMappingFilePath)));
@@ -109,7 +109,7 @@ public void Msbuild()
109109
string testResultFile = Path.Join(testResultPath, "coverage.json");
110110
string cmdArgument = $"test -c {_buildConfiguration} --no-build /p:CollectCoverage=true /p:CoverletOutput=\"{testResultFile}\" /p:DeterministicReport=true /p:CoverletOutputFormat=\"cobertura%2cjson\" /p:Include=\"[coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true";
111111
_output.WriteLine($"Command: dotnet {cmdArgument}");
112-
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
112+
int result = DotnetCli(cmdArgument, out string standardOutput, out string standardError, _testProjectPath);
113113
if (!string.IsNullOrEmpty(standardError))
114114
{
115115
_output.WriteLine(standardError);
@@ -134,16 +134,16 @@ public void Msbuild_SourceLink()
134134
string logFilename = $"{TestContext.Current.TestClass?.TestClassName}.{TestContext.Current.TestMethod?.MethodName}.binlog";
135135
CreateDeterministicTestPropsFile();
136136

137-
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string standardOutput, out string standardError, _testProjectPath);
138-
if (!string.IsNullOrEmpty(standardError))
137+
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string buildOutput, out string buildError, _testProjectPath);
138+
if (!string.IsNullOrEmpty(buildError))
139139
{
140-
_output.WriteLine(standardError);
140+
_output.WriteLine(buildError);
141141
}
142142
else
143143
{
144-
_output.WriteLine(standardOutput);
144+
_output.WriteLine(buildOutput);
145145
}
146-
Assert.Contains("Build succeeded.", standardOutput);
146+
Assert.Contains("Build succeeded.", buildOutput);
147147
string sourceRootMappingFilePath = Path.Combine(_testBinaryPath, _buildConfiguration.ToLowerInvariant(), "CoverletSourceRootsMapping_coverletsample.integration.determisticbuild");
148148

149149
Assert.True(File.Exists(sourceRootMappingFilePath), $"File not found: {sourceRootMappingFilePath}");
@@ -153,7 +153,7 @@ public void Msbuild_SourceLink()
153153
string testResultFile = Path.Join(testResultPath, "coverage.json");
154154
string cmdArgument = $"test -c {_buildConfiguration} --no-build /p:CollectCoverage=true /p:CoverletOutput=\"{testResultFile}\" /p:CoverletOutputFormat=\"cobertura%2cjson\" /p:UseSourceLink=true /p:Include=\"[coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true";
155155
_output.WriteLine($"Command: dotnet {cmdArgument}");
156-
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
156+
int result = DotnetCli(cmdArgument, out string standardOutput, out string standardError, _testProjectPath);
157157
if (!string.IsNullOrEmpty(standardError))
158158
{
159159
_output.WriteLine(standardError);
@@ -183,16 +183,16 @@ public void Collectors()
183183
DeleteLogFiles(testLogFilesPath);
184184
DeleteCoverageFiles(testResultPath);
185185

186-
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string standardOutput, out string standardError, _testProjectPath);
187-
if (!string.IsNullOrEmpty(standardError))
186+
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string buildOutput, out string buildError, _testProjectPath);
187+
if (!string.IsNullOrEmpty(buildError))
188188
{
189-
_output.WriteLine(standardError);
189+
_output.WriteLine(buildError);
190190
}
191191
else
192192
{
193-
_output.WriteLine(standardOutput);
193+
_output.WriteLine(buildOutput);
194194
}
195-
Assert.Contains("Build succeeded.", standardOutput);
195+
Assert.Contains("Build succeeded.", buildOutput);
196196
string sourceRootMappingFilePath = Path.Combine(_testBinaryPath, _buildConfiguration.ToLowerInvariant(), "CoverletSourceRootsMapping_coverletsample.integration.determisticbuild");
197197

198198
Assert.True(File.Exists(sourceRootMappingFilePath), $"File not found: {sourceRootMappingFilePath}");
@@ -202,7 +202,7 @@ public void Collectors()
202202
string runSettingsPath = AddCollectorRunsettingsFile(_testProjectPath, "[coverletsample.integration.determisticbuild]*DeepThought", deterministicReport: true);
203203
string cmdArgument = $"test -c {_buildConfiguration} --no-build --collect:\"XPlat Code Coverage\" --results-directory:\"{testResultPath}\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(testLogFilesPath, "log.txt")}";
204204
_output.WriteLine($"Command: dotnet {cmdArgument}");
205-
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
205+
int result = DotnetCli(cmdArgument, out string standardOutput, out string standardError, _testProjectPath);
206206
if (!string.IsNullOrEmpty(standardError))
207207
{
208208
_output.WriteLine(standardError);
@@ -238,16 +238,16 @@ public void Collectors_SourceLink()
238238
DeleteLogFiles(testLogFilesPath);
239239
DeleteCoverageFiles(testResultPath);
240240

241-
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string standardOutput, out string standardError, _testProjectPath);
242-
if (!string.IsNullOrEmpty(standardError))
241+
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string buildOutput, out string buildError, _testProjectPath);
242+
if (!string.IsNullOrEmpty(buildError))
243243
{
244-
_output.WriteLine(standardError);
244+
_output.WriteLine(buildError);
245245
}
246246
else
247247
{
248-
_output.WriteLine(standardOutput);
248+
_output.WriteLine(buildOutput);
249249
}
250-
Assert.Contains("Build succeeded.", standardOutput);
250+
Assert.Contains("Build succeeded.", buildOutput);
251251
string sourceRootMappingFilePath = Path.Combine(_testBinaryPath, _buildConfiguration.ToLowerInvariant(), "CoverletSourceRootsMapping_coverletsample.integration.determisticbuild");
252252

253253
Assert.True(File.Exists(sourceRootMappingFilePath), $"File not found: {sourceRootMappingFilePath}");
@@ -257,7 +257,7 @@ public void Collectors_SourceLink()
257257
string runSettingsPath = AddCollectorRunsettingsFile(_testProjectPath, "[coverletsample.integration.determisticbuild]*DeepThought", sourceLink: true);
258258
string cmdArgument = $"test -c {_buildConfiguration} --no-build --collect:\"XPlat Code Coverage\" --results-directory:\"{testResultPath}\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(testLogFilesPath, "log.txt")}";
259259
_output.WriteLine($"Command: dotnet {cmdArgument}");
260-
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
260+
int result = DotnetCli(cmdArgument, out string standardOutput, out string standardError, _testProjectPath);
261261
if (!string.IsNullOrEmpty(standardError))
262262
{
263263
_output.WriteLine(standardError);

test/coverlet.integration.tests/DotnetTool.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public void DotnetTool()
3333
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
3434
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
3535
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
36-
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
36+
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string buildOutput, out string buildError);
3737
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
38-
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{outputPath}\"", out standardOutput, out standardError);
38+
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{outputPath}\"", out string standardOutput, out string standardError);
3939
if (!string.IsNullOrEmpty(standardError))
4040
{
4141
_output.WriteLine(standardError);
@@ -51,9 +51,9 @@ public void StandAlone()
5151
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
5252
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
5353
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
54-
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
54+
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string buildOutput, out string buildError);
5555
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
56-
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{outputPath}\"", out standardOutput, out standardError);
56+
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{outputPath}\"", out string standardOutput, out string standardError);
5757
if (!string.IsNullOrEmpty(standardError))
5858
{
5959
_output.WriteLine(standardError);
@@ -70,9 +70,9 @@ public void StandAloneThreshold()
7070
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
7171
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
7272
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
73-
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
73+
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string buildOutput, out string buildError);
7474
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
75-
int cmdExitCode = RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{outputPath}\"", out standardOutput, out standardError);
75+
int cmdExitCode = RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{outputPath}\"", out string standardOutput, out string standardError);
7676
if (!string.IsNullOrEmpty(standardError))
7777
{
7878
_output.WriteLine(standardError);
@@ -98,9 +98,9 @@ public void StandAloneThresholdLine()
9898
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
9999
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
100100
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
101-
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
101+
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string buildOutput, out string buildError);
102102
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
103-
int cmdExitCode = RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{outputPath}\"", out standardOutput, out standardError);
103+
int cmdExitCode = RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{outputPath}\"", out string standardOutput, out string standardError);
104104
if (!string.IsNullOrEmpty(standardError))
105105
{
106106
_output.WriteLine(standardError);
@@ -125,9 +125,9 @@ public void StandAloneThresholdLineAndMethod()
125125
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
126126
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
127127
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
128-
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
128+
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string buildOutput, out string buildError);
129129
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
130-
int cmdExitCode = RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{outputPath}\"", out standardOutput, out standardError);
130+
int cmdExitCode = RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{outputPath}\"", out string standardOutput, out string standardError);
131131
if (!string.IsNullOrEmpty(standardError))
132132
{
133133
_output.WriteLine(standardError);

test/coverlet.integration.tests/coverlet.integration.tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net8.0</TargetFrameworks>
44
<IsPackable>false</IsPackable>
55
<Nullable>enable</Nullable>
66
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
77
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
8+
<OutputType>Exe</OutputType>
89
</PropertyGroup>
910

1011
<ItemGroup>

test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<Nullable>enable</Nullable>
77
<IsTestProject>true</IsTestProject>
88
<IsPackable>false</IsPackable>
9+
<!--<DisableMSBuildAssemblyCopyCheck>true</DisableMSBuildAssemblyCopyCheck>-->
910
</PropertyGroup>
1011

1112
<ItemGroup>

test/coverlet.tests.projectsample.aspmvcrazor.tests/coverlet.tests.projectsample.aspmvcrazor.tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
6+
<OutputType>Exe</OutputType>
67
</PropertyGroup>
78

89
<ItemGroup>

test/coverlet.tests.projectsample.aspnet8.tests/coverlet.tests.projectsample.aspnet8.tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
6+
<OutputType>Exe</OutputType>
67
</PropertyGroup>
78

89
<ItemGroup>

0 commit comments

Comments
 (0)