The #[ignore] annotation marks an individual test for exclusion from ordinary cargo test execution. Use it when a test changes persistent database state and repeated runs could fail, such as inserting a duplicate primary key. section 5.4 section 6.2.2
Ignoring a database-mutating test
Place #[ignore] immediately above the asynchronous test attribute: #[ignore] #[actix_rt::test] async fn post_course_success() { // inserts a course into the database } Running cargo test --bin iter4 then reports post_course_success as ignored while executing the other tests. The ignored test can remain available for deliberate execution when its database side effects are acceptable. section 5.4 section 6.2.2
Apply the annotation when:
- A test inserts a fixed record and a later run could violate a database uniqueness constraint. section 5.4
- A sanity-check suite should exercise retrieval and failure cases without creating new records every time. section 6.2.2
- You want the test implementation preserved while excluding it from the default suite result. section 5.4
#[ignore]
#[actix_rt::test]
async fn post_course_success() {
}
Inspect the minimal attribute placement used to exclude post_course_success from ordinary asynchronous test execution. section 5.4
