tanu
High-performance, async-friendly and ergonomic WebAPI testing framework for Rust.
Overview
tanu is the main crate for the tanu WebAPI testing framework. It provides a complete solution for testing REST APIs with a focus on performance, ergonomics, and type safety.
Key Features
- Fast and Lightweight - Leverages Rust's zero-cost abstractions for minimal overhead
- Type-Safe and Ergonomic - Takes advantage of Rust's strong type system to prevent errors at compile time
- Async/Await Native - Full support for async operations without boilerplate
- Concurrent Execution - Built-in support for running tests concurrently
- Parameterized Testing - Test multiple scenarios with different inputs
- Interactive TUI - Beautiful terminal UI for test execution and monitoring
- CLI Interface - Simple command-line interface for CI/CD integration
- Allure Integration - Generate beautiful HTML test reports
Quick Start
Installation
Add tanu to your Cargo.toml:
[]
= "0.11.0"
= { = "1", = ["full"] }
= "0.6"
Basic Usage
use ;
async
async
async
Running Tests
Run your tests with:
Or use the TUI mode for interactive testing:
CLI Options
Configuration
Create a tanu.toml file to configure your tests:
[[]]
= "api-tests"
= ["slow_test", "flaky_test"]
[]
= 3
= 2.0
= true
= ["1s", "2s", "5s"]
[]
= "blue"
= "green"
= "yellow"
= "magenta"
= "red"
HTTP Client Features
The HTTP client supports:
- JSON Support - Automatic JSON serialization/deserialization
- Form Data - URL-encoded and multipart form data
- Headers - Easy header management
- Cookies - Session management with cookie jars
- Compression - gzip, deflate, brotli, zstd support
- Timeouts - Configurable request timeouts
- Retries - Automatic retry with backoff strategies
Advanced HTTP Examples
use ;
async
async
Assertion Macros
Tanu provides ergonomic assertion macros:
use ;
// Basic boolean assertion
check!;
// Equality assertions
check_eq!;
check_ne!;
// String equality (with better error messages)
check_str_eq!;
Features
Enable optional features based on your needs:
[]
= { = "0.11.0", = ["json", "multipart", "cookies"] }
json- JSON request/response supportmultipart- Multipart form data supportcookies- Cookie jar support for session management
Architecture
The tanu framework consists of several crates:
tanu- Main crate with CLI and application logictanu-core- Core HTTP client, assertions, and test runnertanu-derive- Procedural macros for test discoverytanu-tui- Interactive terminal UI
Examples
Check out the examples directory for more comprehensive examples including:
- REST API testing
- Authentication flows
- File uploads
- Performance testing
Contributing
Contributions are welcome! Please see the contributing guide for details.
License
Licensed under the Apache License 2.0 - see the LICENSE file for details.