Skip to content

Merge AdHoc query tests into shared test bases (ManyToMany, ComplexType, Json) - #38756

Open
AndriySvyryd with Copilot wants to merge 6 commits into
mainfrom
copilot/merge-non-shared-tests-into-shared-bases
Open

Merge AdHoc query tests into shared test bases (ManyToMany, ComplexType, Json)#38756
AndriySvyryd with Copilot wants to merge 6 commits into
mainfrom
copilot/merge-non-shared-tests-into-shared-bases

Conversation

Copilot AI commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Continues #37681
Part of #33526

Consolidates the AdHoc<Name>QueryTestBase families (which derive from NonSharedModelTestBase) into their shared <Name>QueryTestBase<TFixture> counterparts, eliminating duplicated non-shared-model test infrastructure.

Non-shared tests now live under a #region Non-shared test resources in the shared base and rely on the InitializeNonSharedTest/NonSharedStoreName/ListLoggerFactory support already provided by QueryTestBase.

Changes

  • ManyToMany — merged into ManyToManyQueryTestBase + SqlServer/TPC/TPT provider overrides; AdHoc files removed.
  • ComplexType — merged into spec + relational bases and SqlServer/Sqlite provider tests. GUID-keyed roundtrip tests emit non-deterministic SQL and intentionally omit AssertSql.
  • Json — merged spec (JsonQueryTestBase) and relational (JsonQueryRelationalTestBase) bases, carrying over the JsonColumnType abstraction. The nvarchar variant (JsonQuerySqlServerTest) and json-type variant (JsonQueryJsonTypeSqlServerTest, [ConditionalClass] gated on IsJsonTypeSupported) each receive the full override set with their own baselines, since they now both derive from the relational base rather than a shared SqlServer base.

Copilot AI and others added 2 commits August 5, 2026 19:51
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
…ar SqlServer verified)

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
…st classes

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd August 6, 2026 00:28
@AndriySvyryd
AndriySvyryd marked this pull request as ready for review August 6, 2026 00:38
Copilot AI lite review requested due to automatic review settings August 6, 2026 00:38
@AndriySvyryd
AndriySvyryd requested a review from a team as a code owner August 6, 2026 00:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the effort to consolidate “AdHoc” (non-shared model) query tests into the shared *QueryTestBase<TFixture> hierarchies, reducing duplicated non-shared test infrastructure and keeping area-related tests together (Many-to-many, Complex types, JSON).

Changes:

  • Moved non-shared Many-to-many tests into ManyToManyQueryTestBase and added/adjusted SQL Server/TPC/TPT overrides; removed AdHocManyToMany* test types.
  • Moved non-shared ComplexType tests into shared spec/relational bases and provider tests (SqlServer/Sqlite/Cosmos); removed AdHocComplexType* types.
  • Moved non-shared JSON relational tests into JsonQueryRelationalTestBase and adjusted provider seeding/fixtures; removed AdHocJson* types.

Reviewed changes

Copilot reviewed 31 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs Adds SQL Server baselines for newly inlined non-shared Many-to-many tests.
test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerFixture.cs Narrows log category filtering for JSON SQL Server tests.
test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTManyToManyQuerySqlServerTest.cs Adds TPT SQL baselines for newly inlined non-shared Many-to-many tests.
test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCManyToManyQuerySqlServerTest.cs Adds TPC SQL baselines for newly inlined non-shared Many-to-many tests.
test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs Inlines non-shared ComplexType SQL Server assertions/resources into the shared test class.
test/EFCore.SqlServer.FunctionalTests/Query/AdHocManyToManyQuerySqlServerTest.cs Removes redundant AdHoc SQL Server Many-to-many test class.
test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTest.cs Removes redundant AdHoc SQL Server JSON (nvarchar) test class.
test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerJsonTypeTest.cs Removes redundant AdHoc SQL Server JSON-type test class.
test/EFCore.SqlServer.FunctionalTests/Query/AdHocComplexTypeQuerySqlServerTest.cs Removes redundant AdHoc SQL Server ComplexType test class.
test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs Inlines non-shared JSON seeding/behavior into the shared Sqlite JSON test class.
test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs Inlines non-shared ComplexType SQL assertions into the shared Sqlite ComplexType test class.
test/EFCore.Sqlite.FunctionalTests/Query/AdHocManyToManyQuerySqliteTest.cs Removes redundant AdHoc Sqlite Many-to-many test class.
test/EFCore.Sqlite.FunctionalTests/Query/AdHocJsonQuerySqliteTest.cs Removes redundant AdHoc Sqlite JSON test class.
test/EFCore.Sqlite.FunctionalTests/Query/AdHocComplexTypeQuerySqliteTest.cs Removes redundant AdHoc Sqlite ComplexType test class.
test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs Hosts the non-shared Many-to-many tests/resources inside the shared spec base.
test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs Hosts the non-shared ComplexType tests/resources inside the shared spec base.
test/EFCore.Specification.Tests/Query/AdHocManyToManyQueryTestBase.cs Removes redundant AdHoc spec base for Many-to-many.
test/EFCore.Specification.Tests/Query/AdHocComplexTypeQueryTestBase.cs Removes redundant AdHoc spec base for ComplexType.
test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs Hosts the non-shared JSON relational tests/resources inside the shared relational base.
test/EFCore.Relational.Specification.Tests/Query/ComplexTypeQueryRelationalTestBase.cs Hosts the non-shared ComplexType relational tests/resources inside the shared relational base.
test/EFCore.Relational.Specification.Tests/Query/AdHocManyToManyQueryRelationalTestBase.cs Removes redundant AdHoc relational base for Many-to-many.
test/EFCore.Relational.Specification.Tests/Query/AdHocJsonQueryRelationalTestBase.cs Removes redundant AdHoc relational base for JSON.
test/EFCore.Relational.Specification.Tests/Query/AdHocComplexTypeQueryRelationalTestBase.cs Removes redundant AdHoc relational base for ComplexType.
test/EFCore.InMemory.FunctionalTests/Query/AdHocManyToManyQueryInMemoryTest.cs Removes redundant AdHoc InMemory Many-to-many test class.
test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeQueryCosmosTest.cs Inlines non-shared ComplexType Cosmos assertions/resources into the shared Cosmos test class.
test/EFCore.Cosmos.FunctionalTests/Query/AdHocComplexTypeQueryCosmosTest.cs Removes redundant AdHoc Cosmos ComplexType test class.

Comment thread test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs
var contextFactory = await InitializeNonSharedTest<Context35025>();
using var context = contextFactory.CreateDbContext();

var count = await context.TpcBases.ToListAsync();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Assert count

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already addressed in 75e7429: the query result is asserted with Assert.Empty(entities).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already addressed in 75e7429: the query result is asserted with Assert.Empty(entities).

""");
}

public override async Task Can_save_batch_swapping_alternate_key_values_on_complex_type_property()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This test is currently failing, probably due to incorrect database initialization
Make sure to run all Cosmos dunctional tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ad6759b. ComplexTypeToJsonPropertyQueryCosmosTest now passes locally (163 total, 0 failed), and the full Cosmos run had no ComplexType failures; remaining full-run failures were unrelated vector emulator setup failures.

var contextFactory = await InitializeNonSharedTest<Context35025>();
using var context = contextFactory.CreateDbContext();

var count = await context.TpcBases.ToListAsync();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Assert count

Comment thread test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs

builder.Log(CoreEventId.StringEnumValueInJson);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Json_collection_index_in_projection_nested_project_scalar is failing, probably due to incorrect test store initialization.
Make sure all tests assert SQL baseline and run all SqlServer functional tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified in ad6759b. The targeted Json_collection_index_in_projection_nested_project_scalar tests pass for both SqlServer JSON variants, and the full SqlServer run had no JSON failures; remaining full-run failures were unrelated FullTextSearch/SqlAzure environment failures.

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 20:59
Copilot AI requested a review from AndriySvyryd August 7, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 36 changed files in this pull request and generated no new comments.

Suppressed comments (1)

test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs:502

  • SQLite seeding SQL uses square-bracket quoting for the table name (INSERT INTO [Entities]) while the rest of this method uses SQLite-style double quotes ("Entities"). Keeping quoting consistent makes these raw SQL blocks easier to read/copy and avoids confusion when porting between providers.

Comment thread test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerTest.cs Outdated
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 22:02
Copilot AI requested a review from AndriySvyryd August 7, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 36 changed files in this pull request and generated no new comments.

Suppressed comments (1)

test/EFCore.Relational.Specification.Tests/Query/ComplexTypeQueryRelationalTestBase.cs:132

  • In this async test method, the DbContext is disposed with a synchronous using. Since DbContext implements IAsyncDisposable and this file already uses await using in similar non-shared tests, prefer await using here as well to ensure async disposal paths are used consistently (can matter for provider-specific async cleanup).
        var contextFactory = await InitializeNonSharedTest<Context35025>();
        using var context = contextFactory.CreateDbContext();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants