| Crates.io | backend-test-kit |
| lib.rs | backend-test-kit |
| version | 0.0.2 |
| created_at | 2025-01-25 12:39:20.932141+00 |
| updated_at | 2025-01-25 23:36:34.051255+00 |
| description | Provides a set of tools and helpers for testing backend services in Rust. |
| homepage | |
| repository | https://github.com/ukasyah-dev/backend-test-kit |
| max_upload_size | |
| id | 1530568 |
| size | 42,421 |
Provides a set of tools and helpers for testing backend services in Rust.
Add backend-test-kit as a dev dependency:
cargo add --dev backend-test-kit
Here's a simple example of how to use it:
use std::vec;
use backend_test_kit::http::{TestCase, TestSuite};
use serde_json::json;
#[tokio::test]
async fn create_post() {
let test_cases = vec![
TestCase {
json: Some(json!({
"title": "foo",
"body": "bar",
"userId": 1,
})),
expect_status: |s| assert!(s.is_success()),
expect_result: |r| {
assert_eq!(r["id"], 101);
assert_eq!(r["title"], "foo");
assert_eq!(r["body"], "bar");
},
},
];
let test_suite = TestSuite {
method: "POST".to_string(),
url: "https://jsonplaceholder.typicode.com/posts".to_string(),
test_cases,
};
test_suite.run().await;
}