Crate auto_test

Crate auto_test 

Source
Expand description

§AutoTest

A Rust library and CLI tool for automatically generating test stubs for Rust projects.

This crate provides both a command-line interface and a programmatic API for analyzing Rust source code and generating meaningful test templates. It uses AST-based analysis to understand function signatures, parameters, and return types, then generates integration tests with appropriate assertions.

§Quick Start

use auto_test::generate_tests_for_project;

// Generate tests for the current directory
generate_tests_for_project(".")?;

§Architecture

The library is organized into several modules:

  • core: Core analysis and generation logic (see core module)
  • utils: Utility functions for file I/O and filesystem operations
  • config: Configuration management (see config module)
  • error: Error types and handling (see error module)

§Features

  • AST-based Analysis: Uses syn to parse Rust source code accurately
  • Type-aware Generation: Different parameter generation and assertions based on types
  • Integration Tests: Generates tests that call your public API
  • Modular Organization: Creates separate test files per module
  • CLI Tool: Includes a command-line interface for easy usage
  • Configuration System: User-configurable behavior via config files
  • Error Handling: Comprehensive error propagation with helpful messages
  • Progress Indicators: Provides feedback during long operations
  • Parallel Processing: Fast generation on large codebases
  • Git Integration: Respects .gitignore and skips irrelevant files

§Limitations

  • Currently only analyzes public functions (by design)
  • TypeScript support is planned but not yet implemented
  • Complex custom types fall back to Default::default()

See the README for more information.

Modules§

cli
config
Configuration Management
core
Core Module
error
utils

Functions§

generate_tests_for_project
Generate test files for a Rust project with default configuration.
generate_tests_for_project_with_config
Generate test files for a Rust project with custom configuration.