Testing Infrastructure (Contributors)
This document describes DapperMatic's internal testing infrastructure for contributors who want to understand how the library is tested or contribute to the test suite.
Testing Philosophy
DapperMatic's testing approach is built on real database testing using Docker containers rather than mocks or in-memory databases. This ensures that all DDL operations are validated against actual database engines across all supported providers.
Test Infrastructure
Project Structure
The test project is located at tests/MJCZone.DapperMatic.Tests/
and includes:
- Provider-specific test classes for SQL Server, MySQL, PostgreSQL, and SQLite
- Database fixtures using Testcontainers for container management
- Comprehensive method tests covering all DDL operations
Dependencies
Key testing dependencies (from MJCZone.DapperMatic.Tests.csproj
):
xml
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="Testcontainers.MsSql" Version="3.10.0" />
<PackageReference Include="Testcontainers.MySql" Version="3.10.0" />
<PackageReference Include="Testcontainers.PostgreSql" Version="3.10.0" />
<PackageReference Include="Testcontainers.MariaDb" Version="3.10.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageReference Include="Microsoft.Data.SQLite" Version="8.0.7" />
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Npgsql" Version="8.0.3" />
Database Fixtures
Database fixtures extend DatabaseFixtureBase<TContainer>
and manage container lifecycle:
- SQL Server: Multiple version fixtures (2017, 2019, 2022)
- MySQL: MySQL and MariaDB fixtures
- PostgreSQL: PostgreSQL fixture
- SQLite: File-based testing (no container required)
Test Classes
TestBase
: (src) Abstract base with common testing utilitiesDatabaseMethodsTests
: Abstract base for all provider-specific testsSchema Tests
(src): Tests related to database schema operationsTable Tests
(src): Tests related to database table operationsColumn Tests
(src): Tests related to database column operationsPrimary Key Constraint Tests
(src): Tests related to database primary key constraintsUnique Constraint Tests
(src): Tests related to database unique constraintsDefault Constraint Tests
(src): Tests related to database default constraintsCheck Constraint Tests
(src): Tests related to database check constraintsIndex Tests
(src): Tests related to database indexesTable Factory Tests
(src): Tests related to database table factoriesView Tests
(src): Tests related to database views
- Provider-specific test classes inherit from
DatabaseMethodsTests