| Crates.io | auto_test |
| lib.rs | auto_test |
| version | 0.1.2 |
| created_at | 2025-11-22 15:09:42.222421+00 |
| updated_at | 2025-11-24 15:54:45.155999+00 |
| description | Automatically generate test stubs for Rust projects using AST analysis |
| homepage | |
| repository | https://github.com/m-epasta/auto_test |
| max_upload_size | |
| id | 1945418 |
| size | 144,864 |
A Rust library and CLI tool for automatically generating test stubs for Rust projects. Uses AST analysis to understand your code structure and create meaningful integration tests.
syn and quotecargo install auto_test
[dependencies]
auto_test = "0.1.1"
Generate tests for your entire Rust project:
auto_test generate /path/to/your/rust/project
Or from within a project directory:
cd /path/to/your/rust/project
auto_test generate .
AutoTest supports advanced hierarchical configuration for enterprise workflows. Create an .auto_test.toml or .auto_test.yaml file in your project root:
# Project metadata for GitOps workflows
[project]
name = "my_service"
baseline_branch = "main"
# Generation strategy and behavior
[generation]
strategy = "integration" # "integration", "unit", or "property"
output_dir = "tests"
skip_functions = ["internal_", "test_"]
timeout_seconds = 120
# Custom assertion patterns
[generation.custom_assertions]
"MyResult" = "assert_matches!(result, MyResult::Ok(_))"
"MyError" = "assert!(result.is_err())"
# Type-safe parameter generation
[types]
constructor_inference = true
builder_detection = true
[types.mappings]
"MyDomainType" = "MyDomainType::builder().build()"
"ComplexType" = "ComplexType::new(\"default\")"
# Performance and execution control
[performance]
parallel = true
parallel_chunk_size = 25
memory_limit_mb = 512
caching_enabled = false
# File discovery and filtering
[filesystem]
respect_gitignore = true
skip_patterns = [
"**/target/**",
"**/node_modules/**",
"**/dist/**"
]
use auto_test::generate_tests_for_project;
// Generate integration tests for a project
match generate_tests_for_project("./my_project") {
Ok(()) => println!("Tests generated successfully!"),
Err(e) => eprintln!("Error: {}", e),
}
For a project with this structure:
src/
โโโ lib.rs
โโโ cli/
โ โโโ mod.rs
โ โโโ generate.rs
โโโ core/
โโโ mod.rs
โโโ analyzer.rs
AutoTest generates:
tests/
โโโ integration_tests.rs
โโโ cli_generate_tests.rs
โโโ core_analyzer_rust_analyzer_tests.rs
Each test file contains integration tests that call your public APIs:
#[cfg(test)]
mod tests {
use auto_test::*;
#[test]
fn test_your_function_integration() {
// Arrange
// (generated parameter setup)
// Act
let result = auto_test::generate_tests_for_project("/tmp/test");
// Assert
assert!(result.is_ok());
}
}
AutoTest generates test parameters for common Rust types:
String, &str, i32, u64, bool, and other primitive typesVec<T>, Option<T>, and other standard library types&T, &mut T reference typesDefault::default() for complex structsAutoTest generates appropriate assertions based on return types:
Result<T, E> โ Checks for successful operationOption<T> โ Ensures value is presentVec<T> โ Verifies collection is not emptyString/&str โ Confirms content is not emptyLicensed under the MIT License. See LICENSE for details.
See CHANGELOG.md for a list of changes and version history.