Make the existing SQLite fallback reliable and testable when Docker is unavailable

Author: MartinHockCreated May 9, 2026Updated Jul 20, 2026

Description

The functional test infrastructure already contains a SQLite fallback when the SQL Server Testcontainer cannot be started.

However, the current behavior is not fully reliable or consistently testable:

  • CustomWebApplicationFactory falls back to SQLite only for a specific exception type.
  • DockerAvailabilityTests fails the complete test run when Docker is unavailable, even though the remaining functional tests can use SQLite.
  • There is no explicit test verifying that the SQLite fallback is selected and works correctly.
  • The active database provider is not clearly visible in the test output.
  • The current provider selection relies partly on a global environment variable.

Desired behavior

  • SQL Server through Testcontainers remains the preferred provider for full functional test coverage.
  • The functional test suite can run successfully with SQLite when Docker is unavailable or when SQLite is explicitly selected.
  • The SQLite path is covered by automated tests.
  • Docker-specific coverage does not make the SQLite fallback test run fail.
  • The selected database provider is clearly diagnosable.

Possible approach

  • Make the test database provider explicitly selectable, for example through a factory option or dedicated test factory.
  • Add a test verifying that AppDbContext uses SQLite in fallback mode.
  • Add at least one endpoint test that runs against SQLite.
  • Change the Docker availability check so that it does not fail a valid SQLite-only test run.
  • Keep SQL Server/Testcontainers as the default or CI reference path.

Source: ardalis/CleanArchitecture