Rust Integration Test Scaffolder
Scaffold integration tests for LibrAgent following the project's strict testing rules.
Critical Rule
CI / pnpm rust:test runs --lib first, then each tests/*.rs target one at a time.
#[cfg(test)]blocks insidesrc/do run via the sequential--libstep- Prefer
tests/for full Tauri/DB harness coverage (especially Windows-safe root crates) - Windows
--libneeds the ComCtl32 v6 linker dependency frombuild.rs(#2122) test = falseinCargo.tomlkeeps barecargo testfrom auto-building the lib harness; the runner passes--libexplicitly
Template
use sqlx::sqlite::SqlitePoolOptions;
use sea_orm::SqlxSqliteConnector;
use tauri_mcp_agent_lib::migration::Migrator;
use sea_orm_migration::MigratorTrait;
async fn setup_db() -> sea_orm::DatabaseConnection {
let pool = SqlitePoolOptions::new()
.connect("sqlite::memory:")
.await
.unwrap();
let db = SqlxSqliteConnector::from_sqlx_sqlite_pool(pool);
Migrator::up(&db, None).await.unwrap();
db
}
#[tokio::test]
async fn test_descriptive_name() {
let db = setup_db().await;
// Test implementation here
}
Test Categories
Database/Repository Tests
- Test SeaORM entity mappings
- Test repository queries
- Test migration up/down
- Test foreign key constraints
MCP Integration Tests
- Test builtin server tool execution
- Test session isolation
- Test
MCPServiceProxyrouting - Test external MCP server connection
Command Handler Tests
- Test Tauri command inputs/outputs
- Test error handling paths
- Test permission validation
Placement
src-tauri/tests/<module>_tests.rs- Integration tests by module- Use descriptive filenames matching the module being tested
Verification
# Run all integration tests (CI command)
cargo test --tests
# Run specific test file
cargo test --test <file_stem>