Skip to content
Discussion options

You must be logged in to vote

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:

#[cfg(feature = "db-tests")]
mod db_tests {
    #[sqlx::test]
    async fn my_test(pool: sqlx::PgPool) { /* ... */ }
}

Then plain cargo test skips them and cargo test --features db-tests r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stefankreutz
Comment options

Answer selected by stefankreutz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants