Module helpers

Module helpers 

Source
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

HelperPurpose
parse_test_codeParse Rust code string to AST
create_test_astCreate synthetic AST with N if-statements
ConfigBuilderBuild test configurations fluently
create_test_coverageCreate coverage data with specific values
create_test_projectCreate 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§

ConfigBuilder
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.