Skip to content

Reuse a shared SQL Server container for integration tests #1325

Description

@StuartFerguson

Goal

Reduce integration-test startup time by creating one SQL Server Testcontainers instance per test run or shared fixture instead of starting a new SQL Server container for every scenario.

Scope

  • Introduce a shared SQL Server fixture/lifecycle for the integration-test project.
  • Keep SQL Server startup and health checking at fixture/run scope.
  • Use unique database names, schemas, or reliable reset logic so scenarios remain isolated.
  • Ensure dependent containers use the shared SQL Server connection details and mapped host port.
  • Keep cleanup deterministic and compatible with the existing shared-service handling.
  • Consider Testcontainers reuse only after fixture sharing is in place; if enabled, use a stable container identity/label and document cleanup expectations.

Acceptance criteria

  • SQL Server starts at most once for the relevant integration-test run.
  • Scenarios can run without leaking rows, schemas, or migrations into one another.
  • SQL Server is cleaned up when the fixture/test run completes, including failure paths.
  • Parallel execution behavior is documented or explicitly prevented where shared state makes it unsafe.
  • Capture before/after startup timing for the integration-test suite.
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