Skip to content

Allow query test classes to have non-shared tests#37681

Open
roji wants to merge 2 commits intodotnet:mainfrom
roji:NonSharedTests
Open

Allow query test classes to have non-shared tests#37681
roji wants to merge 2 commits intodotnet:mainfrom
roji:NonSharedTests

Conversation

@roji
Copy link
Member

@roji roji commented Feb 12, 2026

  • Allow regular query test classes (extending QueryTestBase) to have non-shared-model tests (see 333526). This allows us to organize tests based on domain/functionality, and not have different test suites/classes just because some test requires a custom non-shared model.
  • Introduced a new QueryFixtureBase test class that all query fixtures extend; this replaces the previous practice of extending SharedStoreFixtureBase and IQueryFixtureBase in each query fixture, now it's just one thing.
  • Merged NonSharedPrimitiveCollectionsQueryTestBase into PrimitiveCollectionsQueryTestBase and removed it as a first demo; @AndriySvyryd if you're good with this approach, I'll also do all the other ad-hoc/non-shared test suites.
  • PrimitiveCollectionsTestBase had ad-hoc, per-type Array_of_int, Array_of_string tests; this is how we used to do things, but we now have the general "type tests", which ideally should contain all test coverage that needs to run for each and every type. This way, a provider just needs to implement the type test for its special type, rather than figure out 100 places where that type needs to be tested. So I moved all of these out to TypeTestBase.Primitive_collection_in_query rather than to PrimitiveCollectionsQueryTestBase.

Closes #33526

@roji roji requested a review from a team as a code owner February 12, 2026 10:05
Copilot AI review requested due to automatic review settings February 12, 2026 10:05
Copy link

Copilot AI left a comment

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 refactors the EF Core query testing infrastructure to allow “non-shared model” (ad-hoc) tests to live inside regular QueryTestBase-derived test classes, reducing the need for parallel “NonShared*” test suites and enabling better organization by domain/feature.

Changes:

  • Added non-shared test initialization support to QueryTestBase (per-test service provider + dedicated non-shared store).
  • Introduced QueryFixtureBase<TContext> to consolidate shared fixture behavior and non-shared store management; removed IFilteredQueryFixtureBase/IBulkUpdatesFixtureBase plumbing in favor of a richer IQueryFixtureBase.
  • Folded non-shared primitive-collection tests into the normal primitive-collection test hierarchy and updated provider-specific baselines accordingly.

Reviewed changes

Copilot reviewed 86 out of 86 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/EFCore.Sqlite.FunctionalTests/Types/SqliteTemporalTypeTest.cs Skips the new Primitive_collection_in_query type test for TimeOnly on SQLite (tracked via issue).
test/EFCore.Sqlite.FunctionalTests/Types/SqliteMiscellaneousTypeTest.cs Skips Primitive_collection_in_query for byte[] type test (reference-equality semantics).
test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs Moves/implements non-shared primitive-collection assertions and adds parameterized-collection-mode configuration.
test/EFCore.Sqlite.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqliteTest.cs Deleted (non-shared coverage moved into regular test class).
test/EFCore.SqlServer.FunctionalTests/Types/Temporal/SqlServerTimeSpanTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Temporal/SqlServerTimeOnlyTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Temporal/SqlServerDateTimeTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Temporal/SqlServerDateTimeOffsetTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Temporal/SqlServerDateTime2TypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Temporal/SqlServerDateOnlyTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/SqlServerSpatialTypeTestBase.cs Disables primitive-collection type test for spatial types and ignores ArrayValue mapping/warnings.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerShortTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerLongTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerIntTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerFloatTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerDoubleTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerDecimalTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Numeric/SqlServerByteTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Miscellaneous/SqlServerStringTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Miscellaneous/SqlServerGuidTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Miscellaneous/SqlServerByteArrayTypeTest.cs Updates baselines and skips Primitive_collection_in_query for byte[].
test/EFCore.SqlServer.FunctionalTests/Types/Miscellaneous/SqlServerBoolTypeTest.cs Updates baselines and adds SQL assertion for Primitive_collection_in_query.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryPolygonTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryPointTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryMultiPolygonTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryMultiPointTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryMultiLineStringTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryLineStringTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geometry/SqlServerGeometryCollectionTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyPolygonTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyPointTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyMultiPolygonTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyMultiPointTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyMultiLineStringTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyLineStringTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Types/Geography/SqlServerGeographyCollectionTypeTest.cs Adds override hook for new base type test method.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs Consolidates non-shared primitive-collection tests and adds parameterized-collection-mode configuration + new ad-hoc tests.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs Adds parameterized-collection-mode configuration.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServer160Test.cs Adds parameterized-collection-mode configuration.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs Adds parameterized-collection-mode configuration.
test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs Deleted (non-shared coverage moved into regular test class).
test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs Removes unnecessary casts when creating contexts from the fixture.
test/EFCore.Specification.Tests/Types/TypeTestBase.cs Adds new Primitive_collection_in_query type test.
test/EFCore.Specification.Tests/Types/TypeFixtureBase.cs Seeds ArrayValue to support primitive-collection type tests.
test/EFCore.Specification.Tests/Types/TypeEntity.cs Adds required ArrayValue property.
test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs Switches filtered expected data retrieval to the new fixture API.
test/EFCore.Specification.Tests/TestUtilities/BulkUpdatesAsserter.cs Refactors bulk-update asserter to depend on IQueryFixtureBase instead of removed bulk-updates fixture interface.
test/EFCore.Specification.Tests/Query/Translations/BasicTypesQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/QueryTestBase.cs Adds the core non-shared-test infrastructure (InitializeNonSharedTest, lifecycle cleanup).
test/EFCore.Specification.Tests/Query/QueryFixtureBase.cs New consolidated fixture base for query tests (shared + non-shared store support).
test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs Moves various previously “NonShared*” primitive-collection tests into this base using InitializeNonSharedTest.
test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext> and updates filtered expected data override.
test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/ManyToManyFieldsQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/JsonQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext> and updates filtered expected data override.
test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs Expands fixture interface responsibilities (store name, filtered expected data, transaction hook, non-shared store plumbing).
test/EFCore.Specification.Tests/Query/IFilteredQueryFixtureBase.cs Deleted (filtered expected data now part of IQueryFixtureBase).
test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/Ef6GroupByTestBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/CompositeKeysQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/ComplexTypeQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryFixtureBase.cs Removes explicit interface implementation and overrides GetSetSourceCreator.
test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Specification.Tests/Query/Associations/AssociationsQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext> and adjusts transaction behavior.
test/EFCore.Specification.Tests/BulkUpdates/NorthwindBulkUpdatesFixture.cs Removes bulk-updates fixture interface and uses override transaction hook pattern.
test/EFCore.Specification.Tests/BulkUpdates/Inheritance/InheritanceBulkUpdatesFixtureBase.cs Removes bulk-updates fixture interface and uses override transaction hook pattern.
test/EFCore.Specification.Tests/BulkUpdates/BulkUpdatesTestBase.cs Broadens fixture constraint to IQueryFixtureBase.
test/EFCore.Relational.Specification.Tests/Types/RelationalTypeFixtureBase.cs Configures primitive collection mapping for the new ArrayValue on TypeEntity<T>.
test/EFCore.Relational.Specification.Tests/TestUtilities/BulkUpdatesAsserter.cs Updates to IQueryFixtureBase and namespace usage after interface removals.
test/EFCore.Relational.Specification.Tests/RelationalComplianceTestBase.cs Updates compliance check to detect query fixtures via QueryFixtureBase inheritance.
test/EFCore.Relational.Specification.Tests/Query/Translations/JsonTranslationsRelationalTestBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Relational.Specification.Tests/Query/PrimitiveCollectionsQueryRelationalTestBase.cs Absorbs former non-shared relational primitive-collection tests; adds parameter translation mode coverage.
test/EFCore.Relational.Specification.Tests/Query/OptionalDependentQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs Migrates fixture to QueryFixtureBase<TContext>.
test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs Deleted (merged into the main relational primitive-collection base).
test/EFCore.Relational.Specification.Tests/Query/Associations/RelationalAssociationsTests.cs Loosens generic constraints and uses fixture-provided context creator.
test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryFixtureBase.cs Migrates fixture to the non-generic QueryFixtureBase.
test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs Moves former non-shared assertions into this test class.
test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs Deleted (non-shared coverage moved into regular test class).

{
_nonSharedServiceProvider?.Dispose();
_nonSharedServiceProvider = null;

Copy link
Member

Choose a reason for hiding this comment

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

A lot of this code is already contained in NonSharedModelTestBase, consider deriving from it and adding the necessary extension points to avoid duplication.

Copy link
Member

Choose a reason for hiding this comment

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

Basically, I'm suggesting extending this approach to other tests, not just for Query

Copy link
Member Author

Choose a reason for hiding this comment

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

I really like that. I've pushed a commit that does this.

The design is still somewhat messy; the (shared) query test infra - with all shared things happening on the fixture - is quite disjoint from the non-shared infra merged into it, which puts stuff on the test and only relies on the fixture to only create the database once. I have various other cleanup/improvements in mind, but it's probably better to do that in a separate PR, after all ad-hoc/non-shared test suites are merged into their respective (currently-shared) test suites.

Take a look and tell me what you think. I'm also OK continuing to push more work into this PR, but it's already quite huge.

Copilot AI review requested due to automatic review settings February 13, 2026 22:52
Copy link

Copilot AI left a comment

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 197 out of 197 changed files in this pull request and generated no new comments.

@roji roji requested a review from AndriySvyryd February 13, 2026 22:55
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.

Consider allowing non-shared (ad-hoc) tests within regular QueryTestBase classes

2 participants