Test modules function exactly like other modules. If you want to separate a module into a different file, the same rules apply. If you then want to conditionally exclude the module from non-test builds, that's what you use the #[cfg(test)] for.
Probably not the best idea, but you can run the binary directly using std::process::Command , if you are still interested in integration tests. The cleanest solution would probably be having a lib.rs.
Just add a lib.rs file, and declare there the modules you want to test in integration AND all the modules declared in main (so that their tests are executed):
cargo test will run all tests EXCEPT the one in main.rs (it runs the inline tests as if it was a library, so it starts at lib.rs to find the modules to test).