Skip to content

Simplify tests by using Testcontainers.Xunit#92

Merged
PhenX merged 5 commits intoPhenX:mainfrom
0xced:Testcontainers.Xunit
Feb 7, 2026
Merged

Simplify tests by using Testcontainers.Xunit#92
PhenX merged 5 commits intoPhenX:mainfrom
0xced:Testcontainers.Xunit

Conversation

@0xced
Copy link
Copy Markdown
Contributor

@0xced 0xced commented Feb 5, 2026

  • 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.

* 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.
Copy link
Copy Markdown
Contributor

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 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.Xunit and introduces a common IDbContextFactory abstraction 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.

Copy link
Copy Markdown
Owner

@PhenX PhenX left a comment

Choose a reason for hiding this comment

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

Thank you very much ! Once the few remaining requested changes handled, I'll be glad to accept the PR

Comment thread tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/Tests/Basic/BasicTestsBase.cs Outdated
var targetFramework = GetType().Assembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault(e => e.Key == "TargetFramework")?.Value ?? "NA";
return CreateBuilder()
.WithReuse(true)
.WithName($"PhenX.EntityFrameworkCore.BulkInsert.Tests.{DbmsName}-{targetFramework}")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

good idea for the custom name !

@0xced
Copy link
Copy Markdown
Contributor Author

0xced commented Feb 7, 2026

I think I have addressed all the requested changes.

Copy link
Copy Markdown
Owner

@PhenX PhenX left a comment

Choose a reason for hiding this comment

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

Thank you!

@PhenX PhenX merged commit 7bbf9c4 into PhenX:main Feb 7, 2026
2 checks passed
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