
quality-unit-testing
by d-o-hub
A modular Rust-based self-learning episodic memory system for AI agents, featuring hybrid storage with Turso (SQL) and redb (KV), async execution tracking, reward scoring, reflection, and pattern-based skill evolution. Designed for real-world applicability, maintainability, and scalable agent workflows.
SKILL.md
name: quality-unit-testing description: 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.
Quality Unit Testing for Rust
Write tests that catch real bugs and provide deployment confidence.
Core Principles
Quality over coverage: Tests should catch real bugs, not just boost percentages.
Quick Reference
Naming: test_<function>_<scenario>_<expected>
#[test]
fn test_process_payment_insufficient_funds_returns_error()
#[tokio::test]
async fn test_withdraw_valid_amount_decreases_balance()
AAA Pattern (Arrange-Act-Assert)
#[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);
}
Isolation
✓ Mock: APIs, databases, file systems, external services ✗ Don't mock: Value types, pure functions, code under test
Single Responsibility
Each test verifies ONE behavior with ONE reason to fail.
Rust-Specific Patterns
// 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 */ } }
Success Metrics
✓ Deploy without manual testing ✓ Test failures pinpoint exact problems ✓ Refactoring doesn't break unrelated tests ✓ Tests run in milliseconds
Workflow
Creating Tests:
- Understand the code behavior
- Identify risks
- Write failing test first (red-green-refactor)
- Apply AAA pattern
- Isolate dependencies
- Verify speed (milliseconds)
Reviewing Tests:
- Run analysis script
- Check naming conventions
- Ensure isolation
- Confirm single responsibility
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
1ヶ月以内に更新
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon



