Simplify tests by using Testcontainers.Xunit#92
Merged
PhenX merged 5 commits intoPhenX:mainfrom Feb 7, 2026
Merged
Conversation
* EnsureConnectedAsync is not needed anymore, the `UntilDatabaseIsAvailable` wait strategy does exactly this. * Don't blindly swallow exceptions on EnsureCreatedAsync(), only do it for SQL Server where it actually happens and with the precise expected exception. * Use in-memory databases for SQLite so that the file system doesn't get polluted with test databases. * Switch from postgis/postgis to imresamu/postgis:17-3.5 in order to support Apple Silicon Macs. * Use the new `Platform` feature of Testconainers 4.10.0 in order to support vibs2006/sql_server_fts on Apple Silicon Macs.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the test infrastructure to use Testcontainers.Xunit fixtures and improves DB setup behavior across providers (including better Apple Silicon support and cleaner SQLite test databases).
Changes:
- Migrates test fixtures to
Testcontainers.Xunitand introduces a commonIDbContextFactoryabstraction for creating provider-specific test contexts. - Updates database initialization logic (removes custom “ensure connected” loops; narrows exception swallowing to expected SQL Server behavior).
- Switches SQLite tests to in-memory databases and updates container images/platform settings for improved cross-architecture compatibility.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/Tests/Various/VariousTestsBase.cs | Switches base test class dependency from container fixture type to IDbContextFactory. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/Tests/Merge/MergeTestsBase.cs | Switches base test class dependency from container fixture type to IDbContextFactory. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/Tests/Geo/GeoTestsBase.cs | Switches base test class dependency from container fixture type to IDbContextFactory. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/Tests/Basic/BasicTestsBase.cs | Switches base test class dependency from container fixture type to IDbContextFactory. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/PhenX.EntityFrameworkCore.BulkInsert.Tests.csproj | Adds assembly metadata and upgrades/adds Testcontainers packages including Testcontainers.Xunit. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContext/TestDbContextBase.cs | Makes ConfigureOptions nullable and throws a clearer exception when missing. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainerSqlite.cs | Moves SQLite tests to in-memory SQLite setup via IDbContextFactory. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainerSqlServer.cs | Migrates SQL Server fixture to Testcontainers.Xunit and uses Platform configuration. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainerPostgreSql.cs | Migrates PostgreSQL fixture to Testcontainers.Xunit and switches PostGIS image for arm64 support. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainerOracle.cs | Migrates Oracle fixture to Testcontainers.Xunit and simplifies connection string usage. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainerMySql.cs | Migrates MySQL fixture to Testcontainers.Xunit and standardizes server version configuration. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainer.cs | Replaces custom container lifecycle/connection checks with DbContainerFixture and wait strategy. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/IDbContextFactory.cs | Introduces a test-local context factory abstraction used by all base test classes. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Benchmark/Providers/LibComparatorSqlServer.cs | Pins SQL Server benchmark container image/tag. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Benchmark/Providers/LibComparatorPostgreSql.cs | Pins PostgreSQL benchmark container image/tag. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Benchmark/Providers/LibComparatorOracle.cs | Uses new OracleBuilder(image) constructor overload. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Benchmark/Providers/LibComparatorMySql.cs | Pins MySQL benchmark container image/tag. |
| tests/PhenX.EntityFrameworkCore.BulkInsert.Benchmark/PhenX.EntityFrameworkCore.BulkInsert.Benchmark.csproj | Upgrades Testcontainers packages for the benchmark project. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PhenX
requested changes
Feb 7, 2026
Owner
PhenX
left a comment
There was a problem hiding this comment.
Thank you very much ! Once the few remaining requested changes handled, I'll be glad to accept the PR
| var targetFramework = GetType().Assembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault(e => e.Key == "TargetFramework")?.Value ?? "NA"; | ||
| return CreateBuilder() | ||
| .WithReuse(true) | ||
| .WithName($"PhenX.EntityFrameworkCore.BulkInsert.Tests.{DbmsName}-{targetFramework}") |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
It's not even actually needed for SQLite tests
Contributor
Author
|
I think I have addressed all the requested changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EnsureConnectedAsync is not needed anymore, the
UntilDatabaseIsAvailablewait strategy does exactly this.Don't blindly swallow exceptions on EnsureCreatedAsync(), only do it for SQL Server where it actually happens and with the precise expected exception.
Use in-memory databases for SQLite so that the file system doesn't get polluted with test databases.
Switch from postgis/postgis to imresamu/postgis:17-3.5 in order to support Apple Silicon Macs.
Use the new
Platformfeature of Testconainers 4.10.0 in order to support vibs2006/sql_server_fts on Apple Silicon Macs.