Skip to content

Commit 2f12e4d

Browse files
committed
Migrate to xunit.v3
1 parent 45dba6b commit 2f12e4d

File tree

102 files changed

+106
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+106
-104
lines changed

.github/workflows/dotnet-build-and-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ jobs:
133133
134134
# Check if the project supports the target framework
135135
if [[ "$target_frameworks" == *"${{ matrix.targetFramework }}"* ]]; then
136-
dotnet test -f ${{ matrix.targetFramework }} -c ${{ matrix.configuration }} $project --no-build -v Normal --logger trx --collect:"XPlat Code Coverage" --results-directory:"TestResults/Coverage/" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByAttribute=GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverageAttribute
136+
dotnet test -f ${{ matrix.targetFramework }} -c ${{ matrix.configuration }} --project $project --no-build -v Normal --report-trx --coverage --results-directory "TestResults/Coverage/" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByAttribute=GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverageAttribute
137137
else
138138
echo "Skipping $project - does not support target framework ${{ matrix.targetFramework }} (supports: $target_frameworks)"
139139
fi
@@ -170,7 +170,7 @@ jobs:
170170
171171
# Check if the project supports the target framework
172172
if [[ "$target_frameworks" == *"${{ matrix.targetFramework }}"* ]]; then
173-
dotnet test -f ${{ matrix.targetFramework }} -c ${{ matrix.configuration }} $project --no-build -v Normal --logger trx
173+
dotnet test -f ${{ matrix.targetFramework }} -c ${{ matrix.configuration }} --project $project --no-build -v Normal --report-trx
174174
else
175175
echo "Skipping $project - does not support target framework ${{ matrix.targetFramework }} (supports: $target_frameworks)"
176176
fi

dotnet/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ dotnet_diagnostic.VSTHRD111.severity = none # Use .ConfigureAwait(bool) is hidde
220220

221221
dotnet_diagnostic.xUnit1004.severity = none # Test methods should not be skipped. Remove the Skip property to start running the test again.
222222
dotnet_diagnostic.xUnit1042.severity = none # Untyped data rows
223+
dotnet_diagnostic.xUnit1051.severity = none
223224

224225
dotnet_diagnostic.RCS1032.severity = none # Remove redundant parentheses.
225226
dotnet_diagnostic.RCS1074.severity = none # Remove redundant constructor.

dotnet/Directory.Packages.props

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@
118118
<!-- Test -->
119119
<PackageVersion Include="FluentAssertions" Version="8.8.0" />
120120
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="9.0.11" />
121-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
122121
<PackageVersion Include="Moq" Version="[4.18.4]" />
123-
<PackageVersion Include="xunit" Version="2.9.3" />
124-
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
125-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.3" />
126-
<PackageVersion Include="xretry" Version="1.9.0" />
127-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
122+
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.0" />
123+
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.0" />
124+
<PackageVersion Include="xunit.v3.assert" Version="3.2.0" />
125+
<PackageVersion Include="xretry.v3" Version="1.0.0-rc2" />
126+
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="2.0.2" />
127+
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />
128128
<!-- Symbols -->
129129
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
130130
<!-- Toolset -->
@@ -139,7 +139,7 @@
139139
<PrivateAssets>all</PrivateAssets>
140140
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
141141
</PackageReference>
142-
<PackageVersion Include="xunit.analyzers" Version="1.23.0" />
142+
<PackageVersion Include="xunit.analyzers" Version="1.25.0" />
143143
<PackageReference Include="xunit.analyzers">
144144
<PrivateAssets>all</PrivateAssets>
145145
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

dotnet/global.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"sdk": {
3-
"version": "9.0.300",
3+
"version": "10.0.100",
44
"rollForward": "latestMajor",
55
"allowPrerelease": false
6+
},
7+
"test": {
8+
"runner": "Microsoft.Testing.Platform"
69
}
710
}

dotnet/tests/AgentConformance.IntegrationTests/AgentConformance.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>$(ProjectsTargetFrameworks)</TargetFrameworks>
5-
<IsTestProject>false</IsTestProject>
5+
<IsTestUtilityProject>true</IsTestUtilityProject>
66
</PropertyGroup>
77

88
<ItemGroup>

dotnet/tests/AgentConformance.IntegrationTests/AgentTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ public abstract class AgentTests<TAgentFixture>(Func<TAgentFixture> createAgentF
1515
{
1616
protected TAgentFixture Fixture { get; private set; } = default!;
1717

18-
public Task InitializeAsync()
18+
public ValueTask InitializeAsync()
1919
{
2020
this.Fixture = createAgentFixture();
2121
return this.Fixture.InitializeAsync();
2222
}
2323

24-
public Task DisposeAsync() => this.Fixture.DisposeAsync();
24+
public async ValueTask DisposeAsync()
25+
{
26+
await this.Fixture.DisposeAsync();
27+
28+
// https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1816
29+
GC.SuppressFinalize(this);
30+
}
2531
}

dotnet/tests/AzureAI.IntegrationTests/AIProjectClientFixture.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,18 @@ private async Task DeleteResponseChainAsync(string lastResponseId)
144144
}
145145
}
146146

147-
public Task DisposeAsync()
147+
public async ValueTask DisposeAsync()
148148
{
149149
if (this._client is not null && this._agent is not null)
150150
{
151-
return this._client.Agents.DeleteAgentAsync(this._agent.Name);
151+
await this._client.Agents.DeleteAgentAsync(this._agent.Name);
152152
}
153153

154-
return Task.CompletedTask;
154+
// https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1816
155+
GC.SuppressFinalize(this);
155156
}
156157

157-
public async Task InitializeAsync()
158+
public async ValueTask InitializeAsync()
158159
{
159160
this._client = new(new Uri(s_config.Endpoint), new AzureCliCredential());
160161
this._agent = await this.CreateChatClientAgentAsync();

dotnet/tests/AzureAI.IntegrationTests/AzureAI.IntegrationTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFrameworks>$(ProjectsTargetFrameworks)</TargetFrameworks>
55
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsDebugTargetFrameworks)</TargetFrameworks>
66
<InjectSharedIntegrationTestCode>True</InjectSharedIntegrationTestCode>
7+
<OutputType>Exe</OutputType>
78
</PropertyGroup>
89

910
<ItemGroup>

dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistent.IntegrationTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFrameworks>$(ProjectsTargetFrameworks)</TargetFrameworks>
55
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsDebugTargetFrameworks)</TargetFrameworks>
66
<InjectSharedIntegrationTestCode>True</InjectSharedIntegrationTestCode>
7+
<OutputType>Exe</OutputType>
78
</PropertyGroup>
89

910
<ItemGroup>

dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentFixture.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

3+
using System;
34
using System.Collections.Generic;
45
using System.Threading.Tasks;
56
using AgentConformance.IntegrationTests;
@@ -86,17 +87,18 @@ public Task DeleteThreadAsync(AgentThread thread)
8687
return Task.CompletedTask;
8788
}
8889

89-
public Task DisposeAsync()
90+
public async ValueTask DisposeAsync()
9091
{
9192
if (this._persistentAgentsClient is not null && this._agent is not null)
9293
{
93-
return this._persistentAgentsClient.Administration.DeleteAgentAsync(this._agent.Id);
94+
await this._persistentAgentsClient.Administration.DeleteAgentAsync(this._agent.Id);
9495
}
9596

96-
return Task.CompletedTask;
97+
// https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1816
98+
GC.SuppressFinalize(this);
9799
}
98100

99-
public async Task InitializeAsync()
101+
public async ValueTask InitializeAsync()
100102
{
101103
this._persistentAgentsClient = new(s_config.Endpoint, new AzureCliCredential());
102104
this._agent = await this.CreateChatClientAgentAsync();

0 commit comments

Comments
 (0)