Write Rust integration tests by creating files in the `tests` directory and running them with `cargo test`.
Write integration tests in Rust by placing test files in a tests directory at the root of your crate and using the #[test] attribute with #[cfg(test)] modules.
// tests/integration_test.rs
use my_crate::add; // Replace 'my_crate' with your actual crate name
#[test]
fn test_add() {
assert_eq!(4, add(2, 2));
}
Run them with cargo test --test integration_test.
Integration tests verify that different parts of your software work together correctly, unlike unit tests which check individual pieces in isolation. You write these tests in a separate folder so they can import your code as an external user would. Think of it as testing the whole car driving down the road rather than just testing the engine in a lab.