A tool that enhances test suites using mutation testing and LLM-guided test generation.
This tool helps improve test coverage by:
- Identifying code mutations that aren't caught by existing tests
- Using LLMs to generate new test cases that specifically target these mutations
- Adding these generated tests to the test suite
The codebase has been refactored to follow SOLID principles:
file_system.py: Handles file system operationsmutation_tester.py: Runs mutation testing using MutMutllm_test_generator.py: Generates tests using an LLMtest_runner.py: Runs tests and verifies their effectivenesscode_analyzer.py: Analyzes code structure and relationshipsmutation_guided_test_generator.py: Main orchestrator classmain.py: Command-line entry pointexample_script.py: Example script demonstrating usage
- Single Responsibility Principle: Each class has one specific responsibility
- Open/Closed Principle: Classes are open for extension but closed for modification
- Liskov Substitution Principle: Each component can be replaced with another implementation
- Interface Segregation Principle: Separated interfaces for different responsibilities
- Dependency Inversion Principle: High-level modules depend on abstractions
from mutation_guided_test_generator import MutationGuidedTestGenerator
# Initialize the generator
generator = MutationGuidedTestGenerator(
source_dir="path/to/source",
test_dir="path/to/tests",
llm_api_key="your_api_key" # Optional
)
# Run the generator
result = generator.run()
print(result)You can also run it from the command line:
python main.py --source_dir path/to/source --test_dir path/to/tests --api_key your_api_keySee example_script.py for a complete working example with a simple calculator module.