19 releases (12 breaking)
| new 0.13.0 | Jan 15, 2026 |
|---|---|
| 0.11.0 | Dec 23, 2025 |
| 0.10.0 | Sep 18, 2025 |
| 0.8.2 | Jul 16, 2025 |
| 0.3.1 | Mar 17, 2025 |
#1084 in Procedural macros
1,179 downloads per month
Used in 3 crates
125KB
2K
SLoC
tanu-core
The core component of the tanu WebAPI testing framework for Rust.
Overview
tanu-core provides the foundational components for building high-performance, async-friendly WebAPI tests in Rust. It contains the essential building blocks that power the tanu testing framework:
- HTTP Client: Async HTTP client built on reqwest with ergonomic API
- Assertion System: Type-safe assertion macros for test validation
- Configuration Management: Flexible configuration system supporting multiple projects
- Test Runner: Async test execution engine with concurrency support
- Error Handling: Clean error propagation using eyre
Key Features
HTTP Client
- Built on reqwest with async/await support
- Automatic JSON serialization/deserialization
- Cookie support (with
cookiesfeature) - Multipart form data support (with
multipartfeature) - Gzip, deflate, brotli, and zstd compression support
Assertion System
The assertion system provides ergonomic macros for test validation:
use tanu_core::{check, check_eq, check_ne, check_str_eq};
// Basic assertions
check!(response.status().is_success(), "Expected successful response");
check_eq!(200, response.status().as_u16());
check_ne!(404, response.status().as_u16());
check_str_eq!("application/json", response.headers()["content-type"]);
Configuration Management
Supports flexible configuration via tanu.toml files:
[[projects]]
name = "api-tests"
test_ignore = ["slow_test"]
[projects.retry]
count = 3
factor = 2.0
jitter = true
delays = ["1s", "2s", "5s"]
Test Discovery
Compile-time test discovery using procedural macros:
#[tanu::test]
async fn test_api_endpoint() -> eyre::Result<()> {
// Test implementation
Ok(())
}
#[tanu::test(1)]
#[tanu::test(2)]
#[tanu::test(3)]
async fn parameterized_test(param: u32) -> eyre::Result<()> {
// Test with parameter
Ok(())
}
Usage
Add tanu-core to your Cargo.toml:
[dependencies]
tanu-core = "0.12.0"
Basic HTTP Test Example
use tanu_core::{check, check_eq, http::Client};
#[tanu::test]
async fn test_get_request() -> eyre::Result<()> {
let client = Client::new();
let response = client
.get("https://httpbin.org/get")
.header("user-agent", "tanu-test")
.send()
.await?;
check!(response.status().is_success());
check_eq!(200, response.status().as_u16());
let json: serde_json::Value = response.json().await?;
check_eq!("tanu-test", json["headers"]["User-Agent"].as_str().unwrap());
Ok(())
}
Features
json- Enables JSON support for HTTP requests (via reqwest)multipart- Enables multipart form data supportcookies- Enables cookie jar support for maintaining session state
Architecture
tanu-core is designed with modularity and extensibility in mind:
http- HTTP client functionality and request/response handlingassertion- Test assertion macros and validation utilitiesconfig- Configuration parsing and managementrunner- Test execution engine with async supporterror- Error types and handling utilities
Integration
tanu-core is typically used through the main tanu crate, but can be used directly for custom testing scenarios or integration into other tools.
For complete examples and documentation, see the main tanu repository.
Dependencies
~25–46MB
~624K SLoC