Testing
Run Tests
Section titled “Run Tests”# All testscargo nextest run
# Specific testcargo nextest run test_splitter_basic
# With outputcargo nextest run --no-captureTest Categories
Section titled “Test Categories”Unit Tests
Section titled “Unit Tests”In-module tests for specific functions:
#[cfg(test)]mod tests { use super::*;
#[test] fn test_parse_create_table() { // ... }}Integration Tests
Section titled “Integration Tests”End-to-end tests in tests/:
#[test]fn test_split_mysql_dump() { let output = Command::new("./target/release/sql-splitter") .args(["split", "tests/fixtures/static/mssql/simple.sql", "-o", "output/"]) .output() .expect("failed to execute");
assert!(output.status.success());}Real-World Verification
Section titled “Real-World Verification”Test against real SQL dumps:
just verify-realworldModel YAML Fuzzing
Section titled “Model YAML Fuzzing”The model_yaml target mutates complete generate model files. It exercises
UTF-8 and YAML rejection, error formatting, model compilation, bounded row
generation, and SQL rendering to an I/O sink. The target runs the public
in-process pipeline. CLI integration tests cover argument parsing and file
handling.
Install cargo-fuzz and the Rust nightly toolchain once:
cargo install cargo-fuzzrustup toolchain install nightlyRun it for 60 seconds, or pass a longer duration:
just fuzz-model-yamljust fuzz-model-yaml 600The run limits each input to 64 KiB, each table to eight rows, each input to five seconds, and each process to explicit allocation and resident-memory bounds. Minimize the accumulated corpus after a long or parallel run:
just fuzz-model-yaml-cminCrashing inputs are written to fuzz/artifacts/model_yaml/. Reproduce and
minimize one with:
cargo +nightly fuzz run model_yaml fuzz/artifacts/model_yaml/<artifact>cargo +nightly fuzz tmin model_yaml fuzz/artifacts/model_yaml/<artifact>Test Fixtures
Section titled “Test Fixtures”Located in tests/fixtures/:
tests/fixtures/├── generated/ # Test data generated at test time (gitignored)└── static/ ├── mysql/ │ ├── duplicate_pk.sql │ ├── escaped_strings.sql │ ├── fk_missing_parent.sql │ └── missing_table.sql ├── postgres/ │ └── copy_with_nulls.sql ├── sqlite/ │ └── minimal_tenant.sql └── mssql/ ├── edge_cases.sql ├── multi_tenant.sql └── simple.sqlWriting Tests
Section titled “Writing Tests”Test a New Feature
Section titled “Test a New Feature”- Create fixture files in
tests/fixtures/static/ - Write unit tests in the module
- Write integration test in
tests/ - Run
cargo nextest run
Test Fixture Example
Section titled “Test Fixture Example”-- tests/fixtures/static/mysql/my_feature.sqlCREATE TABLE test ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100));
INSERT INTO test VALUES (1, 'Alice');INSERT INTO test VALUES (2, 'Bob');Test Code Example
Section titled “Test Code Example”#[test]fn test_my_feature() { let result = my_function("tests/fixtures/static/mysql/my_feature.sql"); assert!(result.is_ok()); assert_eq!(result.unwrap().table_count, 1);}Code Coverage
Section titled “Code Coverage”cargo install cargo-tarpaulincargo tarpaulin --out HtmlOpen tarpaulin-report.html to view coverage.