pub struct TestGenerator { /* private fields */ }Expand description
Test generator for creating test cases from CLI analysis
Implementations§
Source§impl TestGenerator
impl TestGenerator
Sourcepub fn new(analysis: CliAnalysis, categories: Vec<TestCategory>) -> Self
pub fn new(analysis: CliAnalysis, categories: Vec<TestCategory>) -> Self
Create a new test generator
Sourcepub fn with_config(
analysis: CliAnalysis,
categories: Vec<TestCategory>,
config_path: Option<&Path>,
) -> Result<Self>
pub fn with_config( analysis: CliAnalysis, categories: Vec<TestCategory>, config_path: Option<&Path>, ) -> Result<Self>
Create a new test generator with configuration file
Sourcepub fn generate(&self) -> Result<Vec<TestCase>>
pub fn generate(&self) -> Result<Vec<TestCase>>
Generate all test cases based on selected categories
§Examples
use cli_testing_specialist::analyzer::CliParser;
use cli_testing_specialist::generator::TestGenerator;
use cli_testing_specialist::types::TestCategory;
use std::path::Path;
let parser = CliParser::new();
let analysis = parser.analyze(Path::new("/usr/bin/curl"))?;
let generator = TestGenerator::new(
analysis,
vec![TestCategory::Basic, TestCategory::Security, TestCategory::Help]
);
let tests = generator.generate()?;
println!("Generated {} test cases", tests.len());
// Count tests by category
let basic_tests = tests.iter()
.filter(|t| t.category == TestCategory::Basic)
.count();
println!("Basic tests: {}", basic_tests);Sourcepub fn generate_parallel(&self) -> Result<Vec<TestCase>>
pub fn generate_parallel(&self) -> Result<Vec<TestCase>>
Generate tests in parallel using rayon
Automatically chooses optimal parallelization strategy based on workload size. For large CLI tools (10+ subcommands), this provides 2-3x speedup.
§Examples
use cli_testing_specialist::analyzer::CliParser;
use cli_testing_specialist::generator::TestGenerator;
use cli_testing_specialist::types::TestCategory;
use std::path::Path;
let parser = CliParser::new();
let analysis = parser.analyze(Path::new("/usr/bin/kubectl"))?;
let generator = TestGenerator::new(
analysis,
vec![TestCategory::Basic, TestCategory::Security]
);
// Use parallel generation for large CLI tools
let tests = generator.generate_parallel()?;
println!("Generated {} tests in parallel", tests.len());Sourcepub fn generate_with_strategy(&self) -> Result<Vec<TestCase>>
pub fn generate_with_strategy(&self) -> Result<Vec<TestCase>>
Generate tests with automatic strategy selection
This is the recommended method for test generation. It automatically chooses the optimal parallel processing strategy based on:
- Number of test categories
- CLI complexity (options and subcommands)
- Available CPU cores
§Strategy Selection
- Sequential: Small workloads (<20 tests, 1 category)
- CategoryLevel: Medium workloads (20-100 tests, multiple categories)
- TestLevel: Large workloads (100+ tests, 4+ CPU cores)
§Examples
ⓘ
let generator = TestGenerator::new(analysis, categories);
let tests = generator.generate_with_strategy()?;Auto Trait Implementations§
impl Freeze for TestGenerator
impl RefUnwindSafe for TestGenerator
impl Send for TestGenerator
impl Sync for TestGenerator
impl Unpin for TestGenerator
impl UnwindSafe for TestGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more