Skip to main content

Module test_generator

Module test_generator 

Source
Expand description

Intelligent test case generation from parsed Perl code. Test-driven development helpers and generators. Test generator for TDD workflow support

This module provides automatic test generation for Perl code, supporting the red-green-refactor cycle of Test-Driven Development.

§LSP Workflow Integration

Test generation operates within the LSP workflow: Parse → Index → Navigate → Complete → Analyze

  • Parse Stage: Analyzes Perl functions/methods to determine test requirements
  • Index Stage: Standardizes test patterns and identifies edge cases
  • Navigate Stage: Links related test cases and maintains test dependency relationships
  • Complete Stage: Generates test code using appropriate test frameworks (Test::More, Test2::V0)
  • Analyze Stage: Updates test coverage metrics and integrates with workspace symbols

Essential for maintaining high-quality test coverage in enterprise Perl development systems where reliability and correctness are critical business requirements.

§Usage Examples

use perl_parser::test_generator::{TestGenerator, TestFramework};
use perl_parser::{Parser, ast::Node};

let mut parser = Parser::new("sub add { my ($a, $b) = @_; return $a + $b; }");
let ast = parser.parse()?;
let generator = TestGenerator::new(TestFramework::TestMore);
let test_cases = generator.generate_tests(&ast, "sub add { my ($a, $b) = @_; return $a + $b; }");
println!("Generated {} test cases", test_cases.len());

Structs§

CoverageReport
Code coverage metrics from test execution
RefactoringSuggester
Refactoring suggestions for the green-to-refactor phase
RefactoringSuggestion
A specific refactoring suggestion with context and actions
TestCase
Generated test case
TestGenerator
Test generator for creating unit tests from code
TestGeneratorOptions
Configuration options for test generation
TestResults
Results from executing a test suite
TestRunner
Test runner integration for executing Perl tests

Enums§

Priority
Priority level for refactoring suggestions
RefactoringCategory
Categories of refactoring suggestions
TestFramework
Supported Perl test frameworks