Closed jeremyandrews closed 3 years ago
I see three options:
cargo test -- --test-threads 1
HTTPMOCK_MAX_SERVERS
environment variable (its somewhat hidden in the docs: https://docs.rs/httpmock/0.4.5/httpmock/?search=#parallelism). Be aware of the following though: If you set HTTPMOCK_MAX_SERVERS=1
and one of your tests requires more than one MockServer
, this test will be blocked forever waiting for a second MockServer
to become available.serial_test
crate (https://crates.io/crates/serial_test), which is probably the best solution.Thanks for the quick response!
Your first option works, but I don't want to slow down all tests -- most tests can run in parallel and it greatly speeds up all tests. Plus, I don't want tests to fail for someone that doesn't know this is required.
Your second option doesn't work for the reason you state: some of my tests require more than one MockServer
.
Your third option solves my problem perfectly. I've added this as a dev-dependency. Thanks again!
Is there any way to optionally disable parallelism between specific tests? In my project I have some complex tests that use global state and therefor can't be run in parallel. One solution I have found is to move them into their own integration test files, but I'm trying to keep like-tests in the same files.