I have a standard Rust/Cargo-based codebase including the usual src
folder containing production code and the usual tests
folder containing integration tests. The integration tests are so complex that I would like to unit test parts of my integration test logic, to be sure that my integration tests work correctly. As an example, here is a file from my integration test suite that I would like to write unit tests for:
tests/e2e/output.rs
// complicated integration test code here
#[cfg(test)]
mod tests {
#[test]
fn parses_output_correctly() {
// a unit test to verify that the complicated
// integration test logic above works correctly
assert!(false)
}
}
When I run cargo test
it only executes unit tests for the production code in the src
folder, but it doesn't execute this unit test because it is in the tests
folder. Is there a Cargo command that executes all unit tests in the codebase, independent of whether they are in the src
or tests
folder? Alternatively, is there a way to run all unit tests in the tests
folder?