Expand description
Test helper functions for creating test data.
This module provides factory functions and builders for creating common test objects like ASTs, configurations, and coverage data.
§Quick Reference
| Helper | Purpose |
|---|---|
parse_test_code | Parse Rust code string to AST |
create_test_ast | Create synthetic AST with N if-statements |
ConfigBuilder | Build test configurations fluently |
create_test_coverage | Create coverage data with specific values |
create_test_project | Create realistic project file structure |
§Examples
§Creating Test ASTs
ⓘ
use debtmap::testkit::helpers::{parse_test_code, create_test_ast};
// Parse specific code
let ast = parse_test_code("fn foo() { if x { } }");
// Create synthetic AST with 5 if-statements (complexity ~6)
let ast = create_test_ast(5);§Creating Test Configs
ⓘ
use debtmap::testkit::helpers::ConfigBuilder;
let config = ConfigBuilder::new()
.complexity_threshold(15.0)
.coverage_threshold(80.0)
.build();§Creating Test Coverage
ⓘ
use debtmap::testkit::helpers::create_test_coverage;
// 80% coverage: 80 lines hit out of 100
let coverage = create_test_coverage(100, 80);Structs§
- Config
Builder - Builder for creating test configurations.
Functions§
- create_
complex_ project - Create a complex test project with various code patterns.
- create_
coverage_ data - Create coverage data for a file with a specific percentage.
- create_
multi_ function_ ast - Create an AST with multiple functions for testing multi-function analysis.
- create_
nested_ ast - Create an AST with nested conditionals for testing nesting depth.
- create_
test_ ast - Create a synthetic AST with a specific number of if-statements.
- create_
test_ coverage - Create coverage data with specific line and hit counts.
- create_
test_ project - Create a realistic test project environment.
- parse_
test_ code - Parse inline Rust code into an AST.