Skip or ignore all sqlx::tests
#4232
|
Is there a way to instruct I know I can group those tests, and exclude the corresponding modules. But I thought maybe there is a better way to do this? |
Replies: 1 comment 1 reply
|
There isn't a sqlx-specific switch for this. For skipping them ad hoc on a given run, filter by name: For a durable "don't run DB tests unless I ask" setup, put them behind a feature flag and gate the module: #[cfg(feature = "db-tests")]
mod db_tests {
#[sqlx::test]
async fn my_test(pool: sqlx::PgPool) { /* ... */ }
}Then plain |
There isn't a sqlx-specific switch for this.
#[sqlx::test]expands into an ordinary async#[test], so as far as cargo is concerned they're just regular tests and you're limited to libtest's own filtering. Two clean options depending on what you're after:For skipping them ad hoc on a given run, filter by name:
cargo test -- --skip <pattern>(or the inverse, run only them by naming the module path).For a durable "don't run DB tests unless I ask" setup, put them behind a feature flag and gate the module:
Then plain
cargo testskips them andcargo test --features db-testsr…