|
1 | 1 | <Project Sdk="Microsoft.NET.Sdk"> |
2 | 2 |
|
3 | 3 | <PropertyGroup> |
| 4 | + <OutputType>Exe</OutputType> |
4 | 5 | <TargetFramework>net8.0</TargetFramework> |
5 | 6 | <Nullable>enable</Nullable> |
| 7 | + <!-- Should not be needed, see https://github.com/stryker-mutator/stryker-net/pull/3423 --> |
| 8 | + <IsTestProject>true</IsTestProject> |
6 | 9 | </PropertyGroup> |
7 | 10 |
|
8 | 11 | <ItemGroup> |
9 | 12 | <PackageReference Include="AwesomeAssertions" Version="9.3.0" /> |
10 | | - <PackageReference Include="coverlet.collector" Version="6.0.4" PrivateAssets="all" /> |
11 | | - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" /> |
| 13 | + <PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.3.2" /> |
| 14 | + <PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.0.2" /> |
12 | 15 | <PackageReference Include="PublicApiGenerator" Version="11.5.4" /> |
13 | 16 | <PackageReference Include="ReportGenerator" Version="5.5.1" PrivateAssets="all" /> |
14 | 17 | <PackageReference Include="Serilog" Version="4.3.0" /> |
15 | 18 | <PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" /> |
16 | 19 | <PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" /> |
17 | 20 | <PackageReference Include="Verify" Version="31.10.0" GeneratePathProperty="true" /> |
18 | 21 | <PackageReference Include="Verify.XunitV3" Version="31.10.0" /> |
19 | | - <PackageReference Include="xunit.v3" Version="3.2.2" /> |
20 | | - <PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" PrivateAssets="all" /> |
| 22 | + <PackageReference Include="xunit.v3.mtp-v2" Version="3.2.2" /> |
21 | 23 | </ItemGroup> |
22 | 24 |
|
23 | | - <ItemGroup> |
24 | | - <VSTestLogger Include="trx%3BLogFileName=TestResults-$(TargetFramework).trx" Visible="false" Condition="$(ContinuousIntegrationBuild) == 'true'" /> |
25 | | - <VSTestLogger Include="html%3BLogFileName=TestResults-$(TargetFramework).html" Visible="false" /> |
26 | | - </ItemGroup> |
| 25 | + <PropertyGroup Label="xUnit"> |
| 26 | + <!-- UseMicrosoftTestingPlatformRunner is required for JetBrains Rider to see the tests when discovery is configured to use metadata (Settings | Build, Execution, Deployment | Unit Testing | xUnit.net) --> |
| 27 | + <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> |
| 28 | + <!-- TestingPlatformDotnetTestSupport is ignored with the .NET 10 SDK but is required for older SDKs --> |
| 29 | + <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport> |
| 30 | + </PropertyGroup> |
27 | 31 |
|
28 | 32 | <PropertyGroup Label="Coverage"> |
29 | 33 | <RootDirectory>$([System.IO.Directory]::GetParent($(MSBuildProjectDirectory)))</RootDirectory> |
30 | | - <CoverageReportDirectory>$([System.IO.Path]::Combine($(RootDirectory),'coverage',$(TargetFramework)))</CoverageReportDirectory> |
31 | | - <VSTestResultsDirectory Condition="$(ContinuousIntegrationBuild) == 'true'">$(RootDirectory)</VSTestResultsDirectory> |
32 | | - <VSTestResultsDirectory Condition="$(ContinuousIntegrationBuild) != 'true'">$([System.IO.Path]::Combine($(CoverageReportDirectory),'results'))</VSTestResultsDirectory> |
33 | | - <VSTestCollect>XPlat Code Coverage%3BExcludeByAttribute=GeneratedCodeAttribute</VSTestCollect> |
34 | | - <VSTestLogger>@(VSTestLogger)</VSTestLogger> |
| 34 | + <CoverageReportDirectory>$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(RootDirectory),'coverage',$(TargetFramework)))))</CoverageReportDirectory> |
| 35 | + <CoverageReportFile>$([System.IO.Path]::Combine($(CoverageReportDirectory),'$(MSBuildProjectName).cobertura.xml'))</CoverageReportFile> |
| 36 | + <ArgsCoverage>--coverage --coverage-output-format cobertura --coverage-output $(CoverageReportFile) --coverage-settings $([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(MSBuildThisFileDirectory), 'coverage.xml'))))</ArgsCoverage> |
| 37 | + <ArgsTrx Condition="$(ContinuousIntegrationBuild) == 'true'"> --report-trx --report-trx-filename $(MSBuildProjectName).trx --results-directory $(RootDirectory)</ArgsTrx> |
| 38 | + <TestingPlatformCommandLineArguments>$(ArgsCoverage)$(ArgsTrx)</TestingPlatformCommandLineArguments> |
35 | 39 | </PropertyGroup> |
36 | 40 |
|
37 | | - <Target Name="GenerateHtmlCoverageReport" AfterTargets="VSTest" Condition="$(TargetFramework) != ''"> |
| 41 | + <Target Name="GenerateCoverageReports" AfterTargets="VSTest" Condition="$(TargetFramework) != ''"> |
38 | 42 | <ItemGroup> |
39 | | - <CoverageReport Include="$(VSTestResultsDirectory)/*/coverage.cobertura.xml" /> |
| 43 | + <CoverageReport Include="$(CoverageReportDirectory)/*.cobertura.xml" /> |
40 | 44 | </ItemGroup> |
41 | 45 | <ReportGenerator ReportFiles="@(CoverageReport)" TargetDirectory="$(CoverageReportDirectory)" ReportTypes="HtmlInline;TextSummary" /> |
42 | 46 | </Target> |
43 | 47 |
|
44 | | - <!-- Because of https://github.com/microsoft/vstest/issues/2378 --> |
45 | | - <Target Name="MoveCoverageReport" AfterTargets="GenerateHtmlCoverageReport" Condition="$(TargetFramework) != ''"> |
46 | | - <Move SourceFiles="@(CoverageReport)" DestinationFolder="$(CoverageReportDirectory)" /> |
47 | | - <PropertyGroup> |
48 | | - <CoverageReport>@(CoverageReport)</CoverageReport> |
49 | | - </PropertyGroup> |
50 | | - <ItemGroup> |
51 | | - <CoverageReportParentDirectory Include="$([System.IO.Path]::Combine($(CoverageReport),'..'))" Condition="$(CoverageReport) != ''" /> |
52 | | - </ItemGroup> |
53 | | - <RemoveDir Directories="@(CoverageReportParentDirectory)" /> |
54 | | - </Target> |
55 | | - |
56 | | - <Target Name="DisplayCoverageSummary" AfterTargets="MoveCoverageReport" Condition="$(TargetFramework) != ''"> |
| 48 | + <Target Name="DisplayCoverageSummary" AfterTargets="GenerateCoverageReports" Condition="$(TargetFramework) != ''"> |
57 | 49 | <PropertyGroup> |
58 | 50 | <CatCommand Condition="!$([MSBuild]::IsOSPlatform('Windows'))">cat</CatCommand> |
59 | 51 | <CatCommand Condition="$([MSBuild]::IsOSPlatform('Windows'))">type</CatCommand> |
60 | 52 | </PropertyGroup> |
61 | 53 | <Exec WorkingDirectory="$(CoverageReportDirectory)" Command="$(CatCommand) Summary.txt" /> |
62 | 54 | </Target> |
63 | | - |
64 | | - <Target Name="OpenHtmlCoverageReport" AfterTargets="MoveCoverageReport" Condition="$(TargetFramework) != '' AND $(ContinuousIntegrationBuild) != 'true'"> |
| 55 | + |
| 56 | + <Target Name="OpenHtmlCoverageReport" AfterTargets="DisplayCoverageSummary" Condition="$(TargetFramework) != '' AND $(ContinuousIntegrationBuild) != 'true'"> |
65 | 57 | <PropertyGroup> |
66 | 58 | <OpenCommand Condition="$([MSBuild]::IsOSPlatform('Linux'))">xdg-open</OpenCommand> |
67 | 59 | <OpenCommand Condition="$([MSBuild]::IsOSPlatform('OSX'))">open</OpenCommand> |
|
0 commit comments