TestGenerator

Struct TestGenerator 

Source
pub struct TestGenerator { /* private fields */ }
Expand description

Test generator for creating test cases from CLI analysis

Implementations§

Source§

impl TestGenerator

Source

pub fn new(analysis: CliAnalysis, categories: Vec<TestCategory>) -> Self

Create a new test generator

Source

pub fn with_config( analysis: CliAnalysis, categories: Vec<TestCategory>, config_path: Option<&Path>, ) -> Result<Self>

Create a new test generator with configuration file

Source

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);
Source

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());
Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.