Skip to content

test: start database containers only for provider tests - #52

Merged
giammin merged 1 commit into
mainfrom
test/lazy-db-fixtures
Oct 22, 2026
Merged

giammin merged 1 commit into
mainfrom
test/lazy-db-fixtures

Conversation

@giammin

@giammin giammin commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Since #50 the SQL Server and PostgreSQL fixtures were xUnit v3 assembly fixtures. xUnit v3 starts those on every run, so even a filtered unit-only run (for example --filter-class "*.StorageWrapperTests") started both containers and failed without Docker.

Change

  • Share each container through a collection fixture (SqlServerCollection / PostgreSqlCollection, [Collection(...)] on the repository and end-to-end test classes). There is still one container per provider, but it starts only when that provider's tests run.
  • Trade-off: a provider's repository tests and end-to-end tests now run one after the other instead of in parallel.
  • Move NewTableName() to the fixtures as a public static helper, replacing four private copies.
  • AGENTS.md: describe the collection fixtures and why assembly fixtures are avoided.

Verification

  • dotnet build -c Release: 0 warnings, 0 errors.
  • dotnet test --no-build -c Release --filter-class "*.StorageWrapperTests": 19/19 in 0.9s, no containers started.
  • dotnet test --no-build -c Release: 156/156 passed.

xUnit v3 starts assembly fixtures on every run, so since #50 even a
filtered unit-only run started the SQL Server and PostgreSQL containers
and required Docker. Share each container through a collection fixture
instead: it still starts once per provider, but only when that
provider's tests run.

Move the unique table name helper to the fixtures, so the four test
classes no longer keep their own copies.
@giammin
giammin merged commit 2d7bef6 into main Oct 22, 2026
1 check 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.

1 participant