Skip to main content

ferro_rs/testing/
mod.rs

1//! Testing utilities for Ferro framework
2//!
3//! Provides Jest-like testing helpers including:
4//! - `expect!` macro for fluent assertions with clear expected/received output
5//! - `describe!` and `test!` macros for test organization
6//! - `TestDatabase` for isolated database tests
7//! - `TestContainer` for dependency injection in tests
8//! - `TestClient` and `TestResponse` for HTTP testing
9//! - `Factory` and `Fake` for generating test data
10//!
11//! # Example
12//!
13//! ```rust,ignore
14//! use crate::{describe, test, expect};
15//! use crate::testing::{TestDatabase, TestClient, Fake, Factory};
16//!
17//! describe!("UserService", {
18//!     test!("creates a user", async fn(db: TestDatabase) {
19//!         let service = UserService::new();
20//!         let user = service.create(Fake::email()).await.unwrap();
21//!
22//!         expect!(user.email).to_contain("@");
23//!     });
24//!
25//!     test!("lists users via API", async fn(db: TestDatabase) {
26//!         let client = TestClient::new();
27//!
28//!         let response = client.get("/api/users").send().await;
29//!
30//!         response
31//!             .assert_ok()
32//!             .assert_json_has("users");
33//!     });
34//! });
35//! ```
36
37mod expect;
38mod factory;
39mod http;
40
41pub use crate::container::testing::{TestContainer, TestContainerGuard};
42pub use crate::database::testing::TestDatabase;
43pub use expect::{set_current_test_name, Expect};
44pub use factory::{DatabaseFactory, Factory, FactoryBuilder, FactoryTraits, Fake, Sequence};
45pub use http::{TestClient, TestRequestBuilder, TestResponse};