Skip to content

Speed up DatabaseTests by reusing the SQL container #1889

Description

@StuartFerguson

The database test suite is currently dominated by repeated SQL container startup in TransactionProcessor.DatabaseTests/BaseTest.cs. Each test instance creates its own SQL container and runs EnsureCreatedAsync, which makes the suite much slower than necessary even though each test already uses a unique database name.

Goal:

  • Reuse a single SQL Server container across the DatabaseTests suite
  • Keep one isolated database per test
  • Preserve all existing assertions and coverage

Planned work:

  1. Introduce a shared xUnit fixture for SQL Server lifecycle.
  2. Move BaseTest onto that fixture so tests keep unique TestId-based database names but do not start a container per test.
  3. Update the existing test classes to use the shared fixture.
  4. Validate the runtime improvement on the two heaviest classes: MerchantEventTests and TransactionEventTests.

Important constraint:

  • Do not share a database between tests. Isolation must stay intact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions