DSMySQL uses Docker containers to provide a real MySQL 8.0 instance for integration testing.
- Unit Tests (
tests/unit/): In-memory tests, no external dependencies, run fast - Integration Tests (
tests/integration/mysql/): Require a running MySQL 8.0 database
cmake --preset release
cmake --build build/release -j$(nproc)
ctest --preset releaseCTest automatically:
- Starts a MySQL container via Docker Compose
- Runs all unit and integration tests
- Stops the MySQL container
Integration tests read connection parameters from environment variables or tests/integration/.env.
| Variable | Default | Description |
|---|---|---|
DS_MYSQL_TEST_HOST |
127.0.0.1 |
MySQL server hostname |
DS_MYSQL_TEST_PORT |
3307 |
MySQL server port |
DS_MYSQL_TEST_DATABASE |
ds_mysql_test |
Database name |
DS_MYSQL_TEST_USER |
ds_mysql_test_user |
Username |
DS_MYSQL_TEST_PASSWORD |
ds_mysql_test_password |
Password |
The .env file is auto-created from .env.example during CMake configure if missing.
# Start container only
cmake --build build/release --target docker_integration_up
# Stop container
cmake --build build/release --target docker_integration_downSet SKIP_DOCKER_MANAGEMENT=ON to disable Docker fixture management when a MySQL
instance is provided externally (e.g. GitHub Actions service container):
cmake --preset release -DSKIP_DOCKER_MANAGEMENT=ON- Image: MySQL 8.0
- Container Name:
ds_mysql_test - Default Port: 3307 (auto-selects an available port if occupied)
cp tests/integration/.env.example tests/integration/.envThe docker_up.sh script automatically finds an available port starting from 3307.
You can also override it in .env:
DS_MYSQL_TEST_PORT=3308
docker logs ds_mysql_test
docker stop ds_mysql_test && docker rm ds_mysql_test
cmake --build build/release --target docker_integration_up