This document details the comprehensive four-tier test suite for the Random Allocation project.
The project uses a four-tier testing approach for different development and deployment scenarios:
Purpose: Essential functionality checks to catch obvious mistakes
When to use: Quick development feedback, pre-commit checks
Command: python tests/run_tests.py basic or python tests/run_basic_suite.py
- Parameter Validation: Core PrivacyParams class functionality
- Core Functionality: Essential privacy algorithm verification
- Basic Mathematical Properties: Fundamental correctness checks
Purpose: Comprehensive validation including mathematical correctness and type checking
When to use: Before merging, development milestones
Command: python tests/run_tests.py full or python tests/run_full_suite.py
- All BASIC tests plus:
- Extended Methods: Additional allocation methods and direction consistency
- Other Schemes: Cross-method validation with local, Poisson, and shuffle schemes
- Mathematical Properties: Advanced correctness and boundary condition testing
- Type Annotations: Static type checking and compliance validation
Purpose: Complete validation for production readiness
When to use: Before releases, major deployments
Command: python tests/run_tests.py release or python tests/run_release_suite.py
- All FULL tests plus:
- Comprehensive Coverage: Mathematically precise edge cases and monotonicity validation
- Complete Type Validation: Exhaustive type annotation coverage (26 tests)
- Edge Case Testing: 476 mathematically valid boundary condition tests
- Monotonicity Validation: 370 mathematical property tests
Purpose: Research reproducibility and paper experiment validation
When to use: Research validation, paper submission, reproducibility checks
Command: python tests/run_tests.py paper
- All RELEASE tests plus:
- Research Experiments: Bit-exact reproducibility of paper results
- Experiment Validation: Complete paper experiment coverage
tests/
├── run_tests.py # Four-tier hierarchical test runner
├── run_basic_suite.py # Basic suite runner
├── run_full_suite.py # Full suite runner
├── run_release_suite.py # Release suite runner
├── basic/ # Basic functionality tests (10 tests)
│ └── test_basic_01_functionality.py # Parameter validation, Gaussian mechanism
├── full/ # Comprehensive tests (28 tests)
│ ├── test_full_01_additional_allocation_methods.py # Extended methods
│ ├── test_full_02_other_schemes.py # Other schemes
│ └── test_full_03_utility_functions.py # Core utility functions
├── release/ # Release validation tests (872 tests)
│ ├── test_release_01_complete_type_annotations.py # Complete type validation (26 tests)
│ ├── test_release_02_monotonicity.py # Monotonicity validation (370 tests)
│ └── test_release_03_edge_cases.py # Mathematically precise edge cases (476 tests)
├── paper/ # Research tests (Variable)
│ └── test_paper_01_experiments.py # Paper experiments
├── README.md # Test suite overview
└── TEST_STRUCTURE.md # Detailed test organization
Purpose: Validate core functionality and parameter handling
Key Tests:
- Gaussian mechanism baseline verification
- PrivacyParams class creation and validation
- Direction enum functionality
- Basic parameter boundary checks
Purpose: Extended allocation algorithm functionality verification
Key Tests:
- Additional allocation methods beyond core functionality
- Direction consistency across methods
- Extended scheme validation
- Cross-method compatibility
Purpose: Non-allocation privacy scheme validation Key Tests:
- Local differential privacy schemes
- Poisson mechanism testing
- Shuffle privacy validation
- Cross-scheme comparison
Purpose: Core utility function validation Key Tests:
- Search functions and parameter bounds
- Convergence validation utilities
- Mathematical helper functions
- Utility function integration
Purpose: Complete type annotation coverage validation
Key Tests:
- Function return type validation across all modules
- Type conversion testing and compliance
- Callable type annotations verification
- Optional and union type handling
- Complete module coverage validation
Purpose: Comprehensive mathematical monotonicity validation
Key Tests:
- Parameter monotonicity across all allocation schemes
- Direction consistency validation
- Mathematical property preservation
- Cross-scheme monotonicity comparison
- Boundary condition monotonicity
Purpose: Mathematically precise edge case validation
Key Tests:
- Epsilon Edge Cases: Valid epsilon-only scenarios → delta tests (217 tests)
- Delta Edge Cases: Valid delta-only scenarios → epsilon tests (259 tests)
- Mathematical Precision: Only valid epsilon-delta relationships tested
- Function Existence: Only existing functions tested (no missing function skips)
- Boundary Conditions: Extreme parameter validation with computational limits
- Invalid Edge Case (72 skips): Mathematically incompatible parameter combinations
- Documented Bug (29 skips): Known implementation issues
- Computational Timeout (24 skips): Algorithmic complexity limits
Purpose: Research reproducibility and paper experiment validation
- Error condition handling
Purpose: Complete type annotation coverage and validation
Key Tests:
- Type alias compliance
- Constant type annotations
- Function signature completeness
- Runtime type validation
- MyPy integration testing
Purpose: Research reproducibility and paper experiment validation
Key Tests:
- Research Experiment Reproduction: Validates exact reproduction of paper results
- Data Integrity: Ensures experimental data consistency
- Reproducibility Verification: Tests deterministic result generation
# Fast development feedback (< 5 seconds)
python tests/run_tests.py basic
# Comprehensive development testing (< 30 seconds)
python tests/run_tests.py full
# Complete release validation (< 60 seconds)
python tests/run_tests.py release
# Full validation including research experiments
python tests/run_tests.py paper
# Individual suite runners (recommended for focused testing)
python tests/run_basic_suite.py # Basic tests only
python tests/run_full_suite.py # Full tests only
python tests/run_release_suite.py # Release tests only# Skip slow tests
python tests/run_tests.py full --fast
# Stop on first failure
python tests/run_tests.py basic -x
# Verbose output with details
python tests/run_tests.py release --verbose# Run specific test directories
pytest tests/basic/ -v
pytest tests/full/test_full_03_utility_functions.py -v
# Run specific test classes or methods
pytest tests/basic/test_basic_01_functionality.py::TestGaussianMechanismBaseline -v
pytest -k "epsilon" -v # Run tests matching pattern
# Run release tests individually
pytest tests/release/test_release_03_edge_cases.py -v # Edge cases only
pytest tests/release/test_release_02_monotonicity.py -v # Monotonicity only- Total Tests: 924 tests across all tiers
- Mathematical Precision: Edge cases use only valid epsilon-delta relationships
- Function Validation: Only existing functions tested (no missing function skips)
- Performance: All tests complete within designated time limits
- Reliability: Deterministic results with appropriate numerical tolerance
- Type Safety: Complete type annotation coverage and validation
- Type Annotations: 26 tests (24 passed, 2 failed) - 92.3% success
- Monotonicity: 370 tests (349 passed, 21 failed) - 94.3% success
- Edge Cases: 476 tests (345 passed, 6 failed, 125 skipped) - 72.5% success
- 28% test reduction: From 666 to 476 tests (eliminated invalid combinations)
- 60% skip reduction: From 315 to 125 skips (eliminated meaningless skips)
- Mathematical precision: Only valid mathematical relationships tested
- Function existence: Parametrization validates function existence
✅ Modernized test suite - The complete test suite validates:
- Mathematical correctness of all privacy allocation methods with precision
- Comprehensive edge case validation with legitimate boundary conditions
- Complete type annotation coverage and compliance
- Research experiment reproducibility
- Mathematical Validation: Edge cases now use correct epsilon-delta relationships
- Function Existence Checks: Parametrization validates function existence before testing
- Skip Optimization: Eliminated Category 1 ("missing parameters") skips
- Precision Focus: Tests are mathematically meaningful and computationally feasible
- Categorize: Determine appropriate tier (BASIC/FULL/RELEASE/PAPER)
- File Placement: Add to existing files or create focused new files
- Mathematical Validity: Ensure edge cases use valid parameter relationships
- Function Existence: Verify functions exist before parametrization
- Documentation: Update this document with new test descriptions
- Preserve Mathematical Intent: Maintain mathematical correctness and relationships
- Function Validation: Check function existence in parametrization
- Update Documentation: Reflect changes in test descriptions
- Verify Performance: Ensure modifications don't exceed time limits
- Test Isolation: Maintain independence between test cases