Skip to content

Commit 2a29338

Browse files
committed
Update to xUnit v3 on Microsoft Testing Platform v2
1 parent 7956f4d commit 2a29338

File tree

14 files changed

+123
-51
lines changed

14 files changed

+123
-51
lines changed

.github/workflows/Steeltoe.All.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ env:
2121
DOTNET_CLI_TELEMETRY_OPTOUT: 1
2222
DOTNET_NOLOGO: true
2323
SOLUTION_FILE: 'src/Steeltoe.All.sln'
24+
TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput'
2425
COMMON_TEST_ARGS: >-
25-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/TestOutput
26-
--settings coverlet.runsettings --blame-crash --blame-hang-timeout 1m
26+
--no-build --no-progress --configuration Release --results-directory ${{ github.workspace }}/TestOutput
27+
--report-trx --coverage --coverage-settings coverage.config --crashdump --hangdump --hangdump-timeout 1m
2728
2829
jobs:
2930
analyze:
@@ -91,19 +92,19 @@ jobs:
9192
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal
9293

9394
- name: Test
94-
run: dotnet test ${{ env.SOLUTION_FILE }} --filter "${{ matrix.skipIntegrationTests == true && 'Category!=MemoryDumps&Category!=Integration' || 'Category!=MemoryDumps' }}" ${{ env.COMMON_TEST_ARGS }}
95+
run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-query "${{ matrix.skipIntegrationTests == true && '/[(Category!=MemoryDumps)&(Category!=Integration)]' || '/[Category!=MemoryDumps]' }}" ${{ env.COMMON_TEST_ARGS }}
9596

9697
- name: Test (memory dumps)
97-
run: dotnet test src/Management/test/Endpoint.Test --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
98+
run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
9899

99100
- name: Upload crash/hang dumps (on failure)
100101
if: ${{ failure() }}
101102
uses: actions/upload-artifact@v5
102103
with:
103104
name: FailedTestOutput-${{ matrix.os }}
104105
path: |
105-
${{ github.workspace }}/TestOutput/**/*.dmp
106-
${{ github.workspace }}/TestOutput/**/Sequence_*.xml
106+
${{ env.TEST_OUTPUT_DIRECTORY }}/*.dmp
107+
${{ env.TEST_OUTPUT_DIRECTORY }}/Sequence_*.xml
107108
if-no-files-found: ignore
108109

109110
- name: Report test results
@@ -112,14 +113,15 @@ jobs:
112113
with:
113114
name: ${{ matrix.os }} test results
114115
reporter: dotnet-trx
115-
path: '**/*.trx'
116+
path: '${{ env.TEST_OUTPUT_DIRECTORY }}/*.trx'
117+
path-replace-backslashes: true
116118
fail-on-empty: 'true'
117119
fail-on-error: 'false'
118120

119121
- name: Generate code coverage report
120122
uses: danielpalme/ReportGenerator-GitHub-Action@v5
121123
with:
122-
reports: '**/coverage.opencover.xml'
124+
reports: '${{ env.TEST_OUTPUT_DIRECTORY }}/*cobertura.xml'
123125
targetdir: 'coveragereport'
124126
reporttypes: 'MarkdownAssembliesSummary;MarkdownSummaryGithub'
125127
filefilters: '-*.g.cs'

.github/workflows/component-shared-workflow.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ env:
2323
DOTNET_CLI_TELEMETRY_OPTOUT: 1
2424
DOTNET_NOLOGO: true
2525
SOLUTION_FILE: 'src/Steeltoe.${{ inputs.component }}.slnf'
26+
TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput'
2627
COMMON_TEST_ARGS: >-
27-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/TestOutput
28-
--settings coverlet.runsettings --blame-crash --blame-hang-timeout 1m
28+
--no-build --no-progress --configuration Release --results-directory ${{ github.workspace }}/TestOutput
29+
--report-trx --coverage --coverage-settings coverage.config --crashdump --hangdump --hangdump-timeout 1m
2930
3031
jobs:
3132
build:
@@ -81,20 +82,20 @@ jobs:
8182
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal
8283

8384
- name: Test
84-
run: dotnet test ${{ env.SOLUTION_FILE }} --filter "Category!=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
85+
run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-not-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
8586

8687
- name: Test (memory dumps)
8788
if: ${{ inputs.component == 'Management' }}
88-
run: dotnet test src/Management/test/Endpoint.Test --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
89+
run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
8990

9091
- name: Upload crash/hang dumps (on failure)
9192
if: ${{ failure() }}
9293
uses: actions/upload-artifact@v5
9394
with:
9495
name: FailedTestOutput-${{ inputs.OS }}-latest
9596
path: |
96-
${{ github.workspace }}/TestOutput/**/*.dmp
97-
${{ github.workspace }}/TestOutput/**/Sequence_*.xml
97+
${{ env.TEST_OUTPUT_DIRECTORY }}/*.dmp
98+
${{ env.TEST_OUTPUT_DIRECTORY }}/Sequence_*.xml
9899
if-no-files-found: ignore
99100

100101
- name: Report test results
@@ -103,6 +104,7 @@ jobs:
103104
with:
104105
name: ${{ inputs.OS }}-latest test results
105106
reporter: dotnet-trx
106-
path: '**/*.trx'
107+
path: '${{ env.TEST_OUTPUT_DIRECTORY }}/*.trx'
108+
path-replace-backslashes: true
107109
fail-on-empty: 'true'
108110
fail-on-error: 'false'

.github/workflows/sonarcube.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ env:
2222
DOTNET_CLI_TELEMETRY_OPTOUT: 1
2323
DOTNET_NOLOGO: true
2424
SOLUTION_FILE: 'src/Steeltoe.All.sln'
25+
TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput'
2526
SONAR_TEST_ARGS: >-
26-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/TestOutput
27-
--settings coverlet.runsettings -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.UseSourceLink=false
27+
--no-build --no-progress --configuration Release --results-directory ${{ github.workspace }}/TestOutput
28+
--report-trx --coverage --coverage-settings coverage.sonar.config
2829
2930
jobs:
3031
analyze:
@@ -74,17 +75,19 @@ jobs:
7475
env:
7576
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7677
run: >-
78+
# TODO: Revert to OpenCover, see https://github.com/microsoft/testfx/issues/7104
79+
# /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
7780
dotnet sonarscanner begin /k:"SteeltoeOSS_steeltoe" /o:"steeltoeoss" /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
78-
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
81+
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="${{ env.TEST_OUTPUT_DIRECTORY }}/*.xml"
7982
8083
- name: Build solution
8184
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal
8285

8386
- name: Test
84-
run: dotnet test ${{ env.SOLUTION_FILE }} --filter "Category!=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}
87+
run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-not-trait "Category=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}
8588

8689
- name: Test (memory dumps)
87-
run: dotnet test src/Management/test/Endpoint.Test --filter "Category=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}
90+
run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}
8891

8992
- name: End Sonar .NET scanner
9093
if: ${{ !cancelled() && steps.sonar_begin.outcome == 'success' }}

coverage.config

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Configuration>
3+
<!--
4+
This file format is documented at https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md.
5+
CAUTION: Microsoft Testing Platform uses different defaults, see https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-extensions-code-coverage.
6+
-->
7+
<Format>cobertura</Format>
8+
<DeterministicReport>true</DeterministicReport>
9+
<CodeCoverage>
10+
<ModulePaths>
11+
<Exclude>
12+
<ModulePath>.*ConfigurationSchemaGenerator.*</ModulePath>
13+
</Exclude>
14+
</ModulePaths>
15+
<Attributes>
16+
<Exclude>
17+
<Attribute>^System\.ObsoleteAttribute$</Attribute>
18+
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
19+
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
20+
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
21+
</Exclude>
22+
</Attributes>
23+
<Sources>
24+
<Exclude>
25+
<Source>.*\\test\\.*</Source>
26+
</Exclude>
27+
</Sources>
28+
</CodeCoverage>
29+
</Configuration>

coverage.sonar.config

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Configuration>
3+
<!--
4+
This file format is documented at https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md.
5+
CAUTION: Microsoft Testing Platform uses different defaults, see https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-extensions-code-coverage.
6+
-->
7+
<Format>xml</Format>
8+
<DeterministicReport>true</DeterministicReport>
9+
<CodeCoverage>
10+
<ModulePaths>
11+
<Exclude>
12+
<ModulePath>.*ConfigurationSchemaGenerator.*</ModulePath>
13+
</Exclude>
14+
</ModulePaths>
15+
<Attributes>
16+
<Exclude>
17+
<Attribute>^System\.ObsoleteAttribute$</Attribute>
18+
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
19+
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
20+
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
21+
</Exclude>
22+
</Attributes>
23+
<Sources>
24+
<Exclude>
25+
<Source>.*\\test\\.*</Source>
26+
</Exclude>
27+
</Sources>
28+
</CodeCoverage>
29+
</Configuration>

coverlet.runsettings

Lines changed: 0 additions & 16 deletions
This file was deleted.

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"test": {
3+
"runner": "Microsoft.Testing.Platform"
4+
}
5+
}

mtp-test-entitlements.plist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-jit</key>
6+
<true/>
7+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
8+
<true/>
9+
<key>com.apple.security.cs.disable-library-validation</key>
10+
<true/>
11+
<key>com.apple.security.cs.debugger</key>
12+
<true/>
13+
<key>com.apple.security.get-task-allow</key>
14+
<true/>
15+
</dict>
16+
</plist>

nuget.config

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
<packageSources>
44
<clear />
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6+
<add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" />
67
</packageSources>
7-
<packageSourceMapping>
8-
<packageSource key="nuget.org">
9-
<package pattern="*" />
10-
</packageSource>
11-
</packageSourceMapping>
128
</configuration>

shared-test.props

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,27 @@
55
<NoWarn>$(NoWarn);S2094;S3717;SA1602;CA1062;CA1707;NU5104</NoWarn>
66
</PropertyGroup>
77

8+
<PropertyGroup>
9+
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
10+
<!-- Suppress certificate warnings about preview MTP extensions on dev-feed -->
11+
<NoWarn>$(NoWarn);NU3018;NU3027;NU3042</NoWarn>
12+
</PropertyGroup>
13+
814
<ItemGroup>
915
<ProjectReference Condition="'$(MSBuildProjectName)' != 'ConfigurationSchemaGenerator.Tests'"
1016
Include="$(MSBuildThisFileDirectory)\src\Common\test\TestResources\Steeltoe.Common.TestResources.csproj" />
1117
</ItemGroup>
1218

1319
<ItemGroup>
14-
<PackageReference Include="coverlet.collector" Version="$(CoverletVersion)" PrivateAssets="All" />
1520
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
1621
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(MatchTargetFrameworkVersion)" />
1722
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="$(FoundationalVersion)" />
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
23+
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="$(MicrosoftTestingExtensionsCodeCoverageVersion)" />
24+
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="$(MicrosoftTestingPlatformVersion)" />
25+
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" Version="$(MicrosoftTestingPlatformVersion)" />
26+
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$(MicrosoftTestingPlatformVersion)" />
1927
<PackageReference Include="Moq" Version="$(MoqVersion)" />
20-
<PackageReference Include="xunit.v3" Version="$(XunitVersion)" />
21-
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVisualStudioVersion)" />
28+
<PackageReference Include="xunit.v3.mtp-v2" Version="$(XunitVersion)" />
2229
</ItemGroup>
2330

2431
<ItemGroup>

0 commit comments

Comments
 (0)