This document explains how to run tests and generate coverage reports for the Data Validate project.
Install dependencies using Poetry:
poetry installAll commands are managed through the Makefile for task automation.
Run all tests with coverage (uses pyproject.toml configuration).
make testRun tests quickly without coverage (fail-fast mode).
make test-fastRun tests showing only file names with short traceback.
make test-shortRemove temporary files and test reports.
make test-cleanRun specific test modules:
poetry run pytest tests/unit/helpers/common/formatting/ -v
poetry run pytest tests/unit/helpers/base/ -v
poetry run pytest tests/unit/helpers/tools/spellchecker/ -vGenerate all badges (coverage and tests).
make badgesGenerate coverage badge only.
make genbadge-coverageGenerate tests badge only.
make genbadge-testsRemove output data and temporary files.
make cleanAll reports are generated in the dev-reports/ directory:
- HTML:
dev-reports/htmlcov/index.html- Interactive browser report - XML:
dev-reports/coverage.xml- XML format for CI/CD - JUnit:
dev-reports/junit/junit.xml- Test results in JUnit format - Terminal: Coverage displayed directly in terminal output
tests/
├── unit/
│ ├── helpers/
│ │ ├── base/ # Core utilities tests
│ │ │ ├── test_constant_base.py
│ │ │ ├── test_data_args.py
│ │ │ ├── test_file_system_utils.py
│ │ │ ├── test_logger_manager.py
│ │ │ └── test_metadata_info.py
│ │ ├── common/ # Common utilities tests
│ │ │ ├── formatting/ # Formatting functions
│ │ │ ├── generation/ # Data generation
│ │ │ ├── processing/ # Data processing
│ │ │ └── validation/ # Validation logic
│ │ └── tools/ # Tools tests
│ │ ├── data_loader/ # Data loader tests
│ │ ├── locale/ # Internationalization
│ │ └── spellchecker/ # Spell checker tests
│ └── __init__.py
├── conftest.py # Global pytest configuration
└── __init__.py
Test configuration is centralized in pyproject.toml:
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = [
"--verbose",
"--cov=data_validate",
"--cov-report=html:dev-reports/htmlcov",
"--cov-report=xml:dev-reports/coverage.xml",
"--cov-report=term-missing",
"--cov-fail-under=4",
"--junitxml=dev-reports/junit/junit.xml",
]- Framework: pytest with pytest-mock (NO unittest.mock)
- Coverage: 100% required for any new test file
- Minimum threshold: 4% (legacy, will increase as coverage improves)
- Test structure: Must mirror
data_validate/folder hierarchy
- Quick development: Use
make test-fastfor rapid feedback - Detailed coverage: Use
make testthen opendev-reports/htmlcov/index.html - Clean slate: Use
make test-cleanbefore running new tests - Generate badges: Use
make badgesafter running tests - All commands: Use
make helpto see available commands
poetry installCheck if dev-reports/ directory has write permissions:
mkdir -p dev-reports/htmlcov dev-reports/junitEnsure virtual environment is activated:
poetry shellThis is expected for modules without tests. Coverage increases as tests are added.
- See HOW_IT_WORKS.md for architecture details
- See README.md for general project documentation
- See CHANGELOG.md for version history