Allow query test classes to have non-shared tests#37681
Allow query test classes to have non-shared tests#37681roji wants to merge 2 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
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; removedIFilteredQueryFixtureBase/IBulkUpdatesFixtureBaseplumbing in favor of a richerIQueryFixtureBase. - 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; | ||
|
|
There was a problem hiding this comment.
A lot of this code is already contained in NonSharedModelTestBase, consider deriving from it and adding the necessary extension points to avoid duplication.
There was a problem hiding this comment.
Basically, I'm suggesting extending this approach to other tests, not just for Query
There was a problem hiding this comment.
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.
Closes #33526