Skip to content

Commit ec063d1

Browse files
authored
Upgrade to XUnit v3
1 parent d4cb397 commit ec063d1

1,130 files changed

Lines changed: 20615 additions & 20399 deletions

File tree

Some content is hidden

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

.agents/skills/cosmos-provider/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Non-relational provider with its own parallel query pipeline. Uses JSON for docu
1919
## Azure Cosmos DB Emulator for Tests
2020

2121
- `TestEnvironment.InitializeAsync()` auto-starts a `Testcontainers.CosmosDb` container when `Test__Cosmos__DefaultConnection` is not set. Set the env var to use an existing emulator instead.
22-
- Skip tests requiring unsupported features on the Linux emulator with `[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]`.
22+
- Skip tests requiring unsupported features on the Linux emulator with ` [ConditionalFact(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.IsNotLinuxEmulator))]`.

EFCore.slnx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,17 @@
5959
<Project Path="test/EFCore.AspNet.InMemory.FunctionalTests/EFCore.AspNet.InMemory.FunctionalTests.csproj" />
6060
<Project Path="test/EFCore.AspNet.Specification.Tests/EFCore.AspNet.Specification.Tests.csproj" />
6161
<Project Path="test/EFCore.AspNet.Sqlite.FunctionalTests/EFCore.AspNet.Sqlite.FunctionalTests.csproj" />
62-
<Project Path="test/EFCore.AspNet.SqlServer.FunctionalTests/EFCore.AspNet.SqlServer.FunctionalTests.csproj" />
6362
<Project Path="test/EFCore.Cosmos.FunctionalTests/EFCore.Cosmos.FunctionalTests.csproj" />
6463
<Project Path="test/EFCore.Cosmos.Tests/EFCore.Cosmos.Tests.csproj" />
65-
<Project Path="test/EFCore.CrossStore.FunctionalTests/EFCore.CrossStore.FunctionalTests.csproj" />
66-
<Project Path="test/EFCore.Design.Tests/EFCore.Design.Tests.csproj" />
6764
<Project Path="test/EFCore.FSharp.FunctionalTests/EFCore.FSharp.FunctionalTests.fsproj" />
6865
<Project Path="test/EFCore.InMemory.FunctionalTests/EFCore.InMemory.FunctionalTests.csproj" />
6966
<Project Path="test/EFCore.InMemory.Tests/EFCore.InMemory.Tests.csproj" />
70-
<Project Path="test/EFCore.OData.FunctionalTests/EFCore.OData.FunctionalTests.csproj" />
7167
<Project Path="test/EFCore.Proxies.Tests/EFCore.Proxies.Tests.csproj" />
7268
<Project Path="test/EFCore.Relational.Specification.Tests/EFCore.Relational.Specification.Tests.csproj" />
7369
<Project Path="test/EFCore.Relational.Tests/EFCore.Relational.Tests.csproj" />
7470
<Project Path="test/EFCore.Specification.Tests/EFCore.Specification.Tests.csproj" />
7571
<Project Path="test/EFCore.Sqlite.FunctionalTests/EFCore.Sqlite.FunctionalTests.csproj" />
7672
<Project Path="test/EFCore.Sqlite.Tests/EFCore.Sqlite.Tests.csproj" />
77-
<Project Path="test/EFCore.SqlServer.FunctionalTests/EFCore.SqlServer.FunctionalTests.csproj" />
78-
<Project Path="test/EFCore.SqlServer.HierarchyId.Tests/EFCore.SqlServer.HierarchyId.Tests.csproj" />
79-
<Project Path="test/EFCore.SqlServer.Tests/EFCore.SqlServer.Tests.csproj" />
8073
<Project Path="test/EFCore.Tests/EFCore.Tests.csproj" />
8174
<Project Path="test/EFCore.VisualBasic.FunctionalTests/EFCore.VisualBasic.FunctionalTests.vbproj" />
8275
<Project Path="test/Microsoft.Data.Sqlite.Tests/Microsoft.Data.Sqlite.sqlite3.Tests.csproj" />

azure-pipelines-internal-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ extends:
197197
- job: Linux_Cosmos
198198
displayName: 'Linux Cosmos'
199199
condition: notin(variables['Build.Reason'], 'PullRequest', 'Schedule')
200-
timeoutInMinutes: 210
200+
timeoutInMinutes: 300
201201
pool:
202202
name: $(DncEngInternalBuildPool)
203203
demands: ImageOverride -equals 1es-ubuntu-2204

benchmark/Directory.Build.props

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

99
<ItemGroup>
1010
<PackageReference Include="BenchmarkDotNet" />
11-
<PackageReference Include="xunit.assert" VersionOverride="$(XUnitVersion)" />
11+
<PackageReference Include="xunit.v3.assert" VersionOverride="$(XUnitV3Version)" />
1212
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
1313
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
1414
</ItemGroup>

eng/Versions.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
<OpenTelemetryExporterInMemoryVersion>1.15.1</OpenTelemetryExporterInMemoryVersion>
5353
<SQLitePCLRawVersion>3.0.3</SQLitePCLRawVersion>
5454
<SQLite3MCPCLRawBundleVersion>2.3.2</SQLite3MCPCLRawBundleVersion>
55+
<XUnitV3Version>4.0.0-pre.108</XUnitV3Version>
56+
<MicrosoftDotNetXUnitV3ExtensionsVersion>11.0.0-beta.26263.112</MicrosoftDotNetXUnitV3ExtensionsVersion>
57+
<MicrosoftTestingPlatformVersion>2.2.2</MicrosoftTestingPlatformVersion>
5558
</PropertyGroup>
5659

5760
<PropertyGroup Label="Analyzers">

eng/helix.proj

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,89 +41,99 @@
4141
</ItemGroup>
4242

4343
<ItemGroup>
44-
<XUnitProject Include="$(RepoRoot)/test/**/*.csproj"/>
45-
<XUnitProject Include="$(RepoRoot)/test/**/*.fsproj"/>
46-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.Specification.Tests/*.csproj"/>
47-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.AspNet.Specification.Tests/*.csproj"/>
48-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.Relational.Specification.Tests/*.csproj"/>
44+
<XUnitV3Project Include="$(RepoRoot)/test/**/*.csproj"/>
45+
<XUnitV3Project Include="$(RepoRoot)/test/**/*.fsproj"/>
46+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.Specification.Tests/*.csproj"/>
47+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.AspNet.Specification.Tests/*.csproj"/>
48+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.Relational.Specification.Tests/*.csproj"/>
4949
<!-- The trimming and NativeAOT test projects are console programs -->
50-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.TrimmingTests/*.csproj"/>
51-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.NativeAotTests/*.csproj"/>
50+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.TrimmingTests/*.csproj"/>
51+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.NativeAotTests/*.csproj"/>
5252
<!-- API baseline tests require source files and cannot run in Helix -->
53-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.ApiBaseline.Tests/*.csproj"/>
53+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.ApiBaseline.Tests/*.csproj"/>
5454
</ItemGroup>
5555

5656
<!-- Work-around for https://github.com/dotnet/runtime/issues/70758 -->
5757
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`OSX`))'">
58-
<XUnitProject Update="$(RepoRoot)/test/EFCore.InMemory.FunctionalTests/*.csproj;$(RepoRoot)/test/EFCore.Sqlite.FunctionalTests/*.csproj;$(RepoRoot)/test/ef.Tests/*.csproj">
58+
<XUnitV3Project Update="$(RepoRoot)/test/EFCore.InMemory.FunctionalTests/*.csproj;$(RepoRoot)/test/EFCore.Sqlite.FunctionalTests/*.csproj;$(RepoRoot)/test/ef.Tests/*.csproj">
5959
<PreCommands>$(PreCommands); export COMPlus_EnableWriteXorExecute=0</PreCommands>
60-
</XUnitProject>
60+
</XUnitV3Project>
6161
</ItemGroup>
6262

6363
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.10.Amd64`))'">
64-
<XUnitProject Remove="$(CosmosTests)"/>
65-
<XUnitProject Remove="$(SqlServerTests)"/>
66-
<XUnitProject Update="@(XUnitProject)">
64+
<XUnitV3Project Remove="$(CosmosTests)"/>
65+
<XUnitV3Project Remove="$(SqlServerTests)"/>
66+
<XUnitV3Project Update="@(XUnitV3Project)">
6767
<PreCommands>$(PreCommands); set "Test__SqlServer__DefaultConnection=Data Source="</PreCommands>
68-
</XUnitProject>
68+
</XUnitV3Project>
6969
</ItemGroup>
7070

7171
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.11.Arm64`))'">
72-
<XUnitProject Remove="$(SqlServerTests)"/>
73-
<XUnitProject Remove="$(CosmosTests)"/>
74-
<XUnitProject Update="@(XUnitProject)">
72+
<XUnitV3Project Remove="$(SqlServerTests)"/>
73+
<XUnitV3Project Remove="$(CosmosTests)"/>
74+
<XUnitV3Project Update="@(XUnitV3Project)">
7575
<PreCommands>$(PreCommands); set "Test__SqlServer__DefaultConnection=Data Source="</PreCommands>
76-
</XUnitProject>
76+
</XUnitV3Project>
7777
</ItemGroup>
7878

7979
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.11.Amd64.Client`))'">
80-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
81-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
82-
<XUnitProject Include="$(SqlServerTests)">
80+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
81+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
82+
<XUnitV3Project Include="$(SqlServerTests)">
8383
<PreCommands>$(PreCommands); SqlLocalDB start</PreCommands>
84-
</XUnitProject>
84+
</XUnitV3Project>
8585
</ItemGroup>
8686

8787
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.Server2025.Amd64`))'">
88-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
89-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
90-
<XUnitProject Include="$(CosmosTests)">
88+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
89+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
90+
<XUnitV3Project Include="$(CosmosTests)">
9191
<PreCommands>$(PreCommands); call %HELIX_CORRELATION_PAYLOAD%\testing\WaitCosmosEmulator.cmd; set Test__Cosmos__DefaultConnection=https://localhost:8081; set Test__Cosmos__SkipConnectionCheck=true</PreCommands>
92-
</XUnitProject>
92+
</XUnitV3Project>
9393
</ItemGroup>
9494

9595
<!-- Start SqlServer instance for test projects which uses SqlServer on docker. Only run SqlServer tests. -->
9696
<ItemGroup Condition = "'$(HelixTargetQueue.Contains(`helix-sqlserver`))'">
97-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
98-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
99-
<XUnitProject Include="$(SqlServerTests)">
97+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
98+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
99+
<XUnitV3Project Include="$(SqlServerTests)">
100100
<PreCommands>$(PreCommands); export MSSQL_SA_PASSWORD=$(MSSQL_SA_PASSWORD); export Test__SqlServer__DefaultConnection="Server=localhost;;Database=master;;User=sa;;Password=$(MSSQL_SA_PASSWORD);;Connect Timeout=60;;ConnectRetryCount=0;;TrustServerCertificate=True"; /opt/mssql/bin/sqlservr --accept-eula &amp;; sleep 120; </PreCommands>
101-
</XUnitProject>
101+
</XUnitV3Project>
102102
</ItemGroup>
103103

104104
<!-- Run Cosmos tests on Ubuntu with Docker support (testcontainer auto-starts the emulator) -->
105105
<ItemGroup Condition = "'$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64.XL.Open' OR '$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64.XL'">
106-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
107-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
108-
<XUnitProject Include="$(CosmosTests)"/>
106+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
107+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
108+
<XUnitV3Project Include="$(CosmosTests)"/>
109109
</ItemGroup>
110110

111111
<!-- Run tests that don't need SqlServer or Cosmos on bare Ubuntu -->
112112
<ItemGroup Condition = "'$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64.Open' OR '$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64'">
113-
<XUnitProject Remove="$(SqlServerTests)"/>
114-
<XUnitProject Remove="$(CosmosTests)"/>
113+
<XUnitV3Project Remove="$(SqlServerTests)"/>
114+
<XUnitV3Project Remove="$(CosmosTests)"/>
115115
</ItemGroup>
116116

117117
<!-- Remove test projects which require SqlServer or Cosmos from OSX -->
118118
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`OSX`))'">
119-
<XUnitProject Remove="$(SqlServerTests)"/>
120-
<XUnitProject Remove="$(CosmosTests)"/>
119+
<XUnitV3Project Remove="$(SqlServerTests)"/>
120+
<XUnitV3Project Remove="$(CosmosTests)"/>
121+
</ItemGroup>
122+
123+
<!--
124+
Skip tests tagged with the "failing" category. Microsoft.DotNet.XUnitV3Extensions attributes
125+
such as [ConditionalClass]/[ConditionalAssembly] add `category=failing` to tests whose
126+
condition evaluates to false; this filter is what actually skips them at the runner.
127+
128+
This must run AFTER any per-queue ItemGroup that re-Includes XUnitV3Project items.
129+
-->
130+
<ItemGroup>
131+
<XUnitV3Project Update="@(XUnitV3Project)">
132+
<Arguments>$(XUnitV3Arguments) --filter-not-trait category=failing --ignore-exit-code 8</Arguments>
133+
</XUnitV3Project>
121134
</ItemGroup>
122135

123136
<PropertyGroup>
124-
<XUnitPublishTargetFramework>$(NetCurrent)</XUnitPublishTargetFramework>
125-
<XUnitRuntimeTargetFramework>netcoreapp2.0</XUnitRuntimeTargetFramework>
126-
<XUnitArguments>-verbose</XUnitArguments>
127-
<XUnitWorkItemTimeout Condition = "'$(XUnitWorkItemTimeout)' == ''">02:00:00</XUnitWorkItemTimeout>
137+
<XUnitWorkItemTimeout Condition = "'$(XUnitWorkItemTimeout)' == ''">03:00:00</XUnitWorkItemTimeout>
128138
</PropertyGroup>
129139
</Project>

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
],
1010
"errorMessage": "The required .NET SDK wasn't found. Please run ./restore.sh or .\\restore.cmd to install it."
1111
},
12+
"test": {
13+
"runner": "Microsoft.Testing.Platform"
14+
},
1215
"tools": {
1316
"dotnet": "11.0.100-preview.5.26227.104",
1417
"runtimes": {

src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Globalization;
55
using System.Net;
6+
using Azure;
67

78
namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
89

@@ -99,6 +100,7 @@ protected override bool ShouldRetryOn(Exception exception)
99100
CosmosException cosmosException => IsTransient(cosmosException.StatusCode),
100101
HttpException httpException => IsTransient(httpException.Response.StatusCode),
101102
WebException webException => IsTransient((webException.Response as HttpWebResponse)?.StatusCode),
103+
RequestFailedException requestFailed => IsTransient((HttpStatusCode)requestFailed.Status),
102104
_ => false
103105
};
104106

src/EFCore/Metadata/Internal/ForeignKey.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,8 @@ public virtual IDependentKeyValueFactory DependentKeyValueFactory
951951
if (field == null)
952952
{
953953
EnsureReadOnly();
954+
// The principal key value factory creates the dependent key value factory
955+
_ = ((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
954956
}
955957

956958
return field!;

src/EFCore/Metadata/RuntimeForeignKey.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,26 @@ IEnumerable<IReadOnlySkipNavigation> IReadOnlyForeignKey.GetReferencingSkipNavig
259259
/// <inheritdoc />
260260
[DebuggerStepThrough]
261261
IDependentKeyValueFactory<TKey> IForeignKey.GetDependentKeyValueFactory<TKey>()
262-
=> (IDependentKeyValueFactory<TKey>)_dependentKeyValueFactory!;
262+
=> (IDependentKeyValueFactory<TKey>)((IRuntimeForeignKey)this).DependentKeyValueFactory;
263263

264264
/// <inheritdoc />
265265
[DebuggerStepThrough]
266266
IDependentKeyValueFactory IForeignKey.GetDependentKeyValueFactory()
267-
=> _dependentKeyValueFactory!;
267+
=> ((IRuntimeForeignKey)this).DependentKeyValueFactory;
268268

269269
/// <inheritdoc />
270270
IDependentKeyValueFactory IRuntimeForeignKey.DependentKeyValueFactory
271271
{
272272
[DebuggerStepThrough]
273-
get => _dependentKeyValueFactory!;
273+
get
274+
{
275+
if (_dependentKeyValueFactory == null)
276+
{
277+
// The principal key value factory creates the dependent key value factory
278+
_ = ((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
279+
}
280+
return _dependentKeyValueFactory!;
281+
}
274282

275283
[DebuggerStepThrough]
276284
set => _dependentKeyValueFactory = value;

0 commit comments

Comments
 (0)