| Crates.io | tanu-core |
| lib.rs | tanu-core |
| version | 0.10.0 |
| created_at | 2025-01-30 13:50:03.321896+00 |
| updated_at | 2025-09-18 02:47:22.235434+00 |
| description | The core component of tanu-rs |
| homepage | https://github.com/tanu-rs/tanu |
| repository | https://github.com/tanu-rs/tanu |
| max_upload_size | |
| id | 1536402 |
| size | 173,768 |
The core component of the tanu WebAPI testing framework for Rust.
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:
cookies feature)multipart feature)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"]);
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"]
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(())
}
Add tanu-core to your Cargo.toml:
[dependencies]
tanu-core = "0.10.0"
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(())
}
json - Enables JSON support for HTTP requests (via reqwest)multipart - Enables multipart form data supportcookies - Enables cookie jar support for maintaining session statetanu-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 utilitiestanu-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.