Expand description
Testing utilities for Ferro framework
Provides Jest-like testing helpers including:
expect!macro for fluent assertions with clear expected/received outputdescribe!andtest!macros for test organizationTestDatabasefor isolated database testsTestContainerfor dependency injection in testsTestClientandTestResponsefor HTTP testingFactoryandFakefor generating test data
§Example
ⓘ
use crate::{describe, test, expect};
use crate::testing::{TestDatabase, TestClient, Fake, Factory};
describe!("UserService", {
test!("creates a user", async fn(db: TestDatabase) {
let service = UserService::new();
let user = service.create(Fake::email()).await.unwrap();
expect!(user.email).to_contain("@");
});
test!("lists users via API", async fn(db: TestDatabase) {
let client = TestClient::new();
let response = client.get("/api/users").send().await;
response
.assert_ok()
.assert_json_has("users");
});
});Re-exports§
pub use crate::container::testing::TestContainer;pub use crate::container::testing::TestContainerGuard;pub use crate::database::testing::TestDatabase;
Structs§
- Expect
- The main Expect wrapper for fluent assertions
- Factory
Builder - Builder for creating model instances with customizations
- Factory
Traits - Collection of named traits (states) for a factory
- Fake
- Helper for generating fake data
- Sequence
- Convenience function to create a sequence of unique items
- Test
Client - HTTP test client for making requests to the application
- Test
Request Builder - Builder for constructing test requests
- Test
Response - Test response with assertion methods
Traits§
- Database
Factory - Trait for models that can be persisted to database via factories
- Factory
- Trait for models that can be created via factories
Functions§
- set_
current_ test_ name - Set the current test name (called by test! macro)