Loading...
Loading...
Write high-quality Rust unit tests following best practices. Use when writing new tests, reviewing test code, or improving test quality. Emphasizes clear naming, AAA pattern, isolation, and deployment confidence.
npx skill4agent add d-o-hub/rust-self-learning-memory quality-unit-testingtest_<function>_<scenario>_<expected>#[test]
fn test_process_payment_insufficient_funds_returns_error()
#[tokio::test]
async fn test_withdraw_valid_amount_decreases_balance()#[test]
fn test_account_withdraw_decreases_balance() {
// Arrange
let mut account = Account::new(100);
// Act
let result = account.withdraw(30);
// Assert
assert!(result.is_ok());
assert_eq!(account.balance(), 70);
}// Async tests
#[tokio::test]
async fn test_async_operation() { /* ... */ }
// Result-based tests
#[test]
fn test_operation() -> anyhow::Result<()> { /* ... */ }
// Test builders
let episode = TestEpisodeBuilder::new()
.with_task("Test task")
.completed(true)
.build();
// RAII cleanup
struct TestDb(TempDir);
impl Drop for TestDb { fn drop(&mut self) { /* auto cleanup */ } }